Storyboard and Switch Views?

I have an iPad app that uses the storyboard board feature and then I have a separate .xib file for another view. I can switch to the separate view and its fine:


    SecondView *Second = [[SecondView alloc] initWithNibName:nil bundle:nil];
    [self presentModalViewController:Second animated:NO];


But when I am in the Second View and try going back I do everything the same just with the first view controller, but It just goes to a black screen:

  • iOS: Pre install SSL certificate in keychain - programmatically
  • How can I tell Asset Catalog (.xcassets) to use the Same Image for Multiple Image Wells?
  • How to Wait in Objective-C
  • How to disable popup menu items like Select, Select All, Suggest…, Define (on UIWebView)?
  • Amazon sns (push notification) does not send to IOS application
  • Understanding a malloc_history dump
  • -(IBAction)FirstView:(id)sender{
        FirstView *First = [[FirstView alloc] initWithNibName:nil bundle:nil];
        [self presentModalViewController:First animated:NO];

    What do you guys think? Am I doing something wrong? What is the best way to switch views?

    2 Solutions Collect From Internet About “Storyboard and Switch Views?”

    initWithNibName:bundle is for loading nib or xib files.

    If you are loading from a storyboard, you need to use

        FirstView *First= [self.storyboard instantiateViewControllerWithIdentifier:@"IDENTIFIER"];

    IDENTIFIER is defined in your storyboard, it’s in the Utilities, Attributes Inspector on the right side.

    HOWEVER your real problem is that you shouldn’t be loading from the storyboard at all. you should just be calling

    [self dismissModalViewControllerAnimated:YES];

    That call will clean up the presentModalViewController:animated: that you used to put the modal view controller up in the first place.

    You presented SecondView using presentModalViewController:animated:, so you need to dismiss it using dismissModalViewControllerAnimated:.

    - (IBAction)FirstView:(id)sender
        [self dismissModalViewControllerAnimated:YES];