I am trying to switch views on button press event, but when i press the button to switch the view from firstview to second. It shows the secondView for a sec or so and then a blank page appears. Im new to iOS programming so not getting what might be the issue.
Here is my code :
- (IBAction)okPressed:(id)sender {
AppDelegate *mainDelegate = (AppDelegate *)[[UIApplication sharedApplication]delegate];
shipView = [mainDelegate.storyboard instantiateViewControllerWithIdentifier:@"SecondViewController"];
[self.navigationController pushViewController:shipView animated:YES];
The UIStoryBoard is instantiated in AppDelegate class. When the okPressed Method is invoked the SecondViewController is not loaded.
The standard alloc / init will not do anything. You need to either use
initWithNibName:bundle:using the filename of your XIB, orUIStoryboard‘sinstantiateViewControllerWithIdentifier:using the identifier of the controller that you defined in the storyboard file.