I am trying to load a nib file like this:
[[NSBundle mainBundle] loadNibNamed:@"PhotoViewController" owner:self options:nil];
but it makes the app crash
If you're creating the view controller programmatically, you can use the initWithNibName:bundle: view controller method
I.e.
[[myViewcontroller alloc] initWithNibName:@"myNib" bundle:nil];
If you're transitioning to the view controller via storyboard, and want to have the storyboard load that view controller from a particular nib file, you could do the following:
This same question is also answered here: Using XCode storyboard to instantiate view controller that uses XIB for its design