UISplitViewController“在Storyboard中找不到ViewIdentifier” iOS 7出错 [英] UISplitViewController "ViewIdentifier was not found in Storyboard" error with iOS 7

查看:207
本文介绍了UISplitViewController“在Storyboard中找不到ViewIdentifier” iOS 7出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理一个关于UISplitViewController的奇怪错误



我创建了一个库,以便尽可能地处理ViewControllers表示和重用代码。在这段代码中,我使用他们的故事板ID实例化ViewControllers,我用它来切换一个带有SplitViewController的ViewController。



尽管它在iOS 8中运行良好,但它在iOS 7中崩溃时出现此错误。

  Storyboard(< UIStoryboard:0x7f94bb52ccd0>)不包含带有标识符'MySplitViewControllerIdentifier'的视图控制器

发生这种情况的代码是这个

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

我多次检查了我的SplitViewController的配置故事板和故事板ID是正确的。如果它有帮助,这个SplitViewController不是子类。



有人处理类似的东西吗?



谢谢

解决方案

嗯,我有点愚蠢xD



UISplitViewController支持iPhone in iOS 8及更高版本,但我在iOS 7模拟器中尝试。



编辑



<但是这里出现了奇怪的事情。实际上UISplitViewController在带有iOS 7的iPhone中受支持,如果它是初始视图控制器,它就可以工作。如果您尝试加载之后,正如我在我的问题中尝试的那样,您将得到相同的错误。



所以我将我的初始View Controller更改为我的UISplitViewController,当需要它,我改变我的根视图控制器。我可以回到我的SplitViewController,因为[storyboard instantiateInitialViewController]在这种情况下工作正常。



感谢您的时间


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

解决方案

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

这篇关于UISplitViewController“在Storyboard中找不到ViewIdentifier” iOS 7出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆