Application tried to present nil modal view controller in target "Current View Controller"

I have a UIViewController with xib, when I try to present a storyboard view on it, it will work.

I represent him using this

  UIViewController * buddiesOrFacebook = [self.storyboard instantiateViewControllerWithIdentifier:@"BuddiesFBFriends"] ; [self presentViewController:buddiesOrFacebook animated:YES completion:nil]; 
+6
source share
2 answers

Check these things out

  • Check the view manager id if it is the same as what you mentioned in the storyboard enter image description here

  • Make sure your buddiesOrFacebook is not zero. Set a breakpoint on this line, and in the debug area below see if the object is null. If it is nil, then the problem is connecting the storyboard

  • If your current view manager does not start from the storyboard, then get the storyboard object as follows:

     UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil]; UIViewController * buddiesOrFacebook = [storyboard instantiateViewControllerWithIdentifier:@"BuddiesFBFriends"] ; [self presentViewController:buddiesOrFacebook animated:YES completion:nil]; 

Quick update:

 let storyboard = UIStoryboard(name: "MainStoryboard", bundle: nil) var buddiesOrFacebook = storyboard.instantiateViewControllerWithIdentifier("BuddiesFBFriends") self.presentViewController(myViewController, animated: true, completion: nil) 
+17
source

The thing that works for Me is this: enter image description here

You must check the box "Initial view controller" for it to work.

0
source

All Articles