I have a UIViewController
with xib , when I try to present a storyboard view on it , it crashes.
I present it using this
UIViewController * buddiesOrFacebook = [self.storyboard instantiateViewControllerWithIdentifier:@"BuddiesFBFriends"] ;
[self presentViewController:buddiesOrFacebook animated:YES completion:nil];
Check these things
Check the identifier of the viewcontroller, if it is the same that you mentioned in storyboard
Make sure that your buddiesOrFacebook is not nil. Set a breakpoint on that line and on the debug area at the bottom see whether the object is not nil. If it is nil then problem lies in the storyboard connection
If your current viewcontroller is not launched from storyboard then get storyboard object like this :
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
UIViewController * buddiesOrFacebook = [storyboard instantiateViewControllerWithIdentifier:@"BuddiesFBFriends"] ;
[self presentViewController:buddiesOrFacebook animated:YES completion:nil];
Swift Update:
let storyboard = UIStoryboard(name: "MainStoryboard", bundle: nil)
var buddiesOrFacebook = storyboard.instantiateViewControllerWithIdentifier("BuddiesFBFriends")
self.presentViewController(myViewController, animated: true, completion: nil)
The thing that works for Me is :
You have to mark the box is Initial View Controller to make it work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With