I have two xib files. I start with “ViewController.xib” and when the user clicks a button it loads a different xib file named “GamePage.xib”.
The code of the button is:
-(IBAction)startButtonClicked{
UIViewController *gamePage = [[UIViewController alloc] initWithNibName:@"GamePage" bundle:nil];
[self presentViewController:gamePage animated:NO completion:nil];
}
When the button is clicked, the second xib is shown on screen, but its “viewDidLoad” method don’t run…
Why is that?
This does not seem correct.
viewDidLoadis probably running but it isviewDidLoadof Apple’sUIViewController. You should use your class instead ofUIViewControllerwhen you initialize it. In general you should use the class which viewDidLoad you need called.