jason white
jason white

Reputation: 711

iOS PresentModalViewController not working

I am inside a root view controller. and then allocate the secondviewcontroller

         SecondViewControl *second=[[SecondViewControl alloc] init];
         [self presentModalViewController:second animated:NO];

The second viewcontroller 's view not showing up

AddSubView method works though. [self.view addSubView:second.view];

why presetModalViewController is not working?

Upvotes: 0

Views: 358

Answers (1)

Tim
Tim

Reputation: 60110

Usually you'll allocate the SecondViewControl with a .xib file that actually defines the user interface. Consider using a line like this (broken for readability):

SecondViewControl *second = [[SecondViewControl alloc]
                             initWithNibName:@"SecondView" 
                             bundle:nil];

Without the accompanying .xib to define the view, you may be left with a view controller that doesn't have the necessary properties set to actually support user interaction, and so presentModalViewController: may have trouble there.

Upvotes: 1

Related Questions