I'm trying to present a standard ViewController
modally, but can't figure out how to do it. The view controller will have buttons which will ultimately trigger the dismissing actions, so I don't need to wrap it in a NavigationController
. Also, I'm doing all of this programmatically, without .xibs.
Here's the code I'm using:
- (void)viewDidAppear:(BOOL)animated {
NSLog(@"view did appear within rootviewcontroller");
WelcomeViewController *welcome = [[WelcomeViewController alloc] init];
[self presentModalViewController:welcome animated:true];
[welcome release];
}
The problem is that I haven't set the WelcomeViewController's
view, so loadView is not getting run, which means no content is being drawn to the screen.
Every example I find, including Apple's, uses either a .xib to initialize the ViewController, a NavigationController that adds a RootViewController, or both. My understanding is that loadView is called automatically for you in both of these scenarios. http://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/ModalViewControllers/ModalViewControllers.html#//apple_ref/doc/uid/TP40007457-CH111-SW3
Where do I configure my WelcomeViewController's
view? Right there after the alloc/init? Inside WelcomeViewController's
init method?
Thanks!
Override the
loadView
method in your subclass. See View Controller Programming Guide for iOS.