Pop-up modal with UITableView on iPhone

Posted by Meltemi on Stack Overflow See other posts from Stack Overflow or by Meltemi
Published on 2010-03-23T23:53:31Z Indexed on 2010/03/24 0:03 UTC
Read the original article Hit count: 699

I need to pop up a quick dialog for the user to select one option in a UITableView from a list of roughly 2-5 items. Dialog will be modal and only take up about 1/2 of screen. I go back and forth between how to handle this. Should I subclass UIView and make it a UITableViewDelegate & DataSource?

I'd also prefer to lay out this view in IB. So to display I'd do something like this from my view controller (assume I have a property in my view controller for DialogView *myDialog;)

NSArray* nibViews = [[NSBundle mainBundle] loadNibNamed:@"DialogView" owner:myDialog options:nil];
myDialog = [nibViews objectAtIndex:0];
[self.view addSubview:myDialog];

problem is i'm trying to pass owner:myDialog which is nil as it hasn't been instantiated...i could pass owner:self but that would make my view controller the File's Owner and that's not how that dialog view is wired in IB.

So that leads me to think this dialog wants to be another full blown UIViewController... But, from all I've read you should only have ONE UIViewController per screen so this confuses me because I could benefit from viewDidLoad, etc. that come along with view controllers...

Can someone please straighten this out for me?

© Stack Overflow or respective owner

Related posts about cocoa-touch

Related posts about iphone