QuickDialogTableView as a subview #68

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
5 participants

I made a slight change to your QuickDialogController in order to add the table view as a subview. This allows me to set a background image without the horrible tiling effect associated with grouped tables.

The change did not break the sample application, so I assume it's safe to include, but you might want to run a few more tests.

@escoz escoz closed this Feb 14, 2012

yaoquan commented Feb 19, 2012

Hi @escoz would you have any example to set the background for the table and not have the tiling effect of group tables that @goblindegook has mentioned?

I too, seem to have this problem currently

Thanks.

Owner

escoz commented Feb 25, 2012

Hey guys, apologies for the delay. Here's what I would do in my own controller that inherits from QuickDialogViewController:

  • (void)loadView {
    [super loadView];
    self.quickDialogTableView.backgroundColor = [UIColor clearColor];
    UIView *background = [[UIView alloc] init];
    background.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"texture"]];
    [background addSubview:self.quickDialogTableView];

    self.view = background;
    }

Hi @escoz sorry to bother you again and thanks for answering my other issues :-)

How can that (adding a background image) be done now? In my QuickDialogController subclass (there is no QuickDialogViewController) I tried this:


- (void)loadView
{
    [super loadView];

    self.quickDialogTableView.backgroundColor = [UIColor clearColor];

    // Background image
    UIImageView *backgroundImage = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Default.png"]] autorelease];
    backgroundImage.contentMode = UIViewContentModeTop;

    [backgroundImage addSubview:self.quickDialogTableView];
    self.view = backgroundImage;
}

but this only has the effect of hiding the tableview …
Any idea?

Thanks in advance,
Shukuyen

UPDATE: Nevermind, had to set the frame of backgroundImage -.-

Owner

escoz commented Mar 21, 2012

You're releasing the backgroundImageview.. QuickDialog uses ARC for memory management.

I do this, it works:

  • (void)loadView
    {
    UIView *background = [[UIView alloc] init];
    background.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"imagename"]];
    self.quickDialogTableView.backgroundColor = [UIColor clearColor];
    self.quickDialogTableView.backgroundView = nil;
    [background addSubview:self.quickDialogTableView];
    self.view = background;
    }

I am using QuickDialog in a non-arc project, so the release stuff is ok.

I had to add the image view and the qtable to a uiview and set the image view frame - now it's working :)

Thanks for your library, learning it one step at a time ;)

You're releasing the backgroundImageview.. QuickDialog uses ARC for memory management.

I do this, it works:

  • (void)loadView
    {
    UIView *background = [[UIView alloc] init];
    background.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"imagename"]];
    self.quickDialogTableView.backgroundColor = [UIColor clearColor];
    self.quickDialogTableView.backgroundView = nil;
    [background addSubview:self.quickDialogTableView];
    self.view = background;
    }

Reply to this email directly or view it on GitHub:
#68 (comment)

As a reference, I wanted to do something similar (add a QuickDialog form as a subview to a controller already created in Storyboard). The following demo code in viewWillAppear suffices (note that QuickDialogController *qdc is an instance variable):

    QRootElement *root = [[QRootElement alloc] init];
    root.grouped = YES;

    QSection *section = [[QSection alloc] init];
    QLabelElement *label = [[QLabelElement alloc] initWithTitle:@"Hello" Value:@"world!"];
    [section addElement:label];
    [root addSection:section];

    QSection *submit = [[QSection alloc] init];
    QButtonElement *submitButton = [[QButtonElement alloc] init];
    submitButton.key = @"button";
    submitButton.title = @"Login";
    submitButton.onSelected = ^{
        NSLog(@"onsubmit");
    };
    [submit addElement:submitButton];
    [root addSection:submit];

    qdc = [QuickDialogController controllerForRoot:root];
    qdc.view.backgroundColor = [UIColor clearColor];
    CGRect qdcFrame = qdc.view.frame;
    qdcFrame.size.width = 200.f;
    qdcFrame.size.height = 200.f;
    qdc.view.frame = qdcFrame;

    UIView *qdView = [[UIView alloc] initWithFrame:CGRectMake(260.f, 65.f, 220.f, 200.f)];
    [qdView addSubview: qdc.view];
    [self.view addSubview: qdView];

There are a few disadvantages of this: if the form is longer than the vertical space available, it'll start to scroll within it's own table view - not the entire UI view on the screen. Also, the keyboard will likely overlap the form elements and the built-in behavior to handle this is circumvented. As well, with sub-forms (adding QRootElements to other QRootElements) don't naturally throw up "back" buttons.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment