【发布时间】:2015-12-01 08:40:07
【问题描述】:
我正在使用Storyboard 并希望通过单击标签栏项目来推送视图控制器以在UITabBarController 中显示。
为此,我使用现有的ViewController 链接到在Storyboard 上创建的TabBarController 并使用以下代码。但是,我得到了异常,Storyboard 不包含标识符为“SwitchViewController”的视图控制器
func tabBarController(tabBarController: UITabBarController, shouldSelectViewController viewController: UIViewController) -> Bool {
let switchViewController = self.storyboard?.instantiateViewControllerWithIdentifier("SwitchViewController")
self.presentViewController(switchViewController, animated: true, completion: nil)
return false
}
更新:我在Main.storyboard 中为SwitchViewController 添加了Storyboard ID,并对上面的代码进行了注释。当我移动到此选项卡时,应用程序失败并出现同样的错误
我正在使用 iOS 8 和 Xcode 7。请帮助
【问题讨论】:
-
我使用了正确的代码,但我的第一个
ViewController缺少导致此问题的NavigationController的rootViewController关系。
标签: ios objective-c swift uiviewcontroller storyboard