UISplitViewController “ViewIdentifier was not found in Storyboard” error with iOS 7

心不动则不痛 提交于 2019-12-11 01:34:26

问题


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


回答1:


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



来源:https://stackoverflow.com/questions/28693173/uisplitviewcontroller-viewidentifier-was-not-found-in-storyboard-error-with-io

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!