Search code examples
iosobjective-ciphoneios7

UISplitViewController "ViewIdentifier was not found in Storyboard" error with iOS 7


I'm dealing with an odd error around an UISplitViewController

I created a library in order to deal with ViewControllers presentation and reuse code as much as possible. Within this code I instantiate ViewControllers using their storyboard IDs and I'm using to switch a ViewController with a SplitViewController.

Despite it works fine in iOS 8, it crashes in iOS 7 with this error.

Storyboard (<UIStoryboard: 0x7f94bb52ccd0>) doesn't contain a view controller with identifier 'MySplitViewControllerIdentifier'

The code where this happens is this

+(UIViewController *) instantiateStoryboard:(UIStoryboard *) storyboard
                     withViewIdentifier:(NSString *) identifier
{
  @try {
    if ([identifier isEqualToString:@""] || identifier == nil) {
        return [storyboard instantiateInitialViewController];
    }
    else {
        //HERE IT CRASHES !!!!!!
        return [storyboard instantiateViewControllerWithIdentifier:identifier];
    }
  }
  @catch (NSException *exception) {
    NSLog(ERROR_NO_VIEWCONTROLLER_FOUND, [self class], identifier, storyboard.description);
  }
}

I checked several times the config of this SplitViewController on my storyboard and the Storyboard ID is correct. If it helps, this SplitViewController is not subclassed.

Someone dealt with something similar?

Thanks


Solution

  • Well, I'm a little stupid xD

    UISplitViewController supports iPhone in iOS 8 and later, but i was trying in iOS 7 simulator.

    EDIT

    But here comes the weird thing. Actually UISplitViewController is supported in iPhone with iOS 7, and it works IF IT'S THE INITIAL VIEW CONTROLLER. If you try to load after, as i tried in my question, you'll get the same error.

    So I change my initial View Controller to my UISplitViewController and, when need it, I change my root view controller. I can came back to my SplitViewController because [storyboard instantiateInitialViewController] works fine in this case.

    Thanks for your time