一周后我打开了我的项目,看来对于所有新的UIViewController
我创建于StoryBoard
, instantiateViewControllerWithIdentifier
返回为零。一切ViewControllers
项目中已经存在的工作正常。
GCHConnectViewController* gchCVC = [self.storyboard instantiateViewControllerWithIdentifier:@"GchConnect"];
navigationController.viewControllers = @[gchCVC];
第一行返回零,我最初的想法是self.storyboard
返回零,所以我尝试了这个并设置了断点。
if (self.storyboard != nil) {
GCHConnectViewController* gchCVC = [self.storyboard instantiateViewControllerWithIdentifier:@"GchConnect"];
navigationController.viewControllers = @[gchCVC];
}
它会进入 if 并在第二行崩溃。
我还添加了课程和storyboard
身份证正确。
如果我尝试加载另一个ViewController
已经存在了,它可以工作,但不是新的。
似乎无法弄清楚问题是什么。任何帮助表示赞赏。
我有一个导航抽屉。切换到其他 ViewController,除了标识符为“GchConnect”的 ViewController(即 indexPath.section == 1 和 indexpath.row == 0 )有效。它们都在同一个故事板中
如果您有多个故事板,self.storyboard
返回当前的那个UIViewController
您需要检查“GhConnect”的故事板名称。并实例化该故事板故事板名称:捆绑: https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIStoryboard_Class/#//apple_ref/occ/clm/UIStoryboard/storyboardWithName:bundle:
UIStoryboard storyboard = [UIStoryboard storyboardWithName:bundle:nil];
GCHConnectViewController* gchCVC = [storyboard instantiateViewControllerWithIdentifier:@"GchConnect"];
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)