Bla*_*ard 2 uinavigationcontroller ios swift
当用户点击按钮时,我尝试在导航控制器中更改我的视图控制器,因此我声明了以下代码:
if standingsViewController == nil {
standingsViewController = StandingsViewController()
splitViewController!.delegate = standingsViewController
}
var vc = splitViewController!.viewControllers[1] as UINavigationController
vc.setViewControllers([standingsViewController], animated: true)
Run Code Online (Sandbox Code Playgroud)
但是,这会导致错误:fatal error: attempt to bridge an implicitly unwrapped optional containing nil在最后一行.
UINavigationController的setViewControllers: animated:方法是在Swift中正确定义的,那么如何解决问题呢?
当我尝试将其更改为您的信息时[standingsViewController]!,它甚至没有通过编译,因为[AnyObject] is not identical to [AnyObject]!.
我在Swift中使用Xcode 6.1 beta.
看起来你忘了打开包装:
vc.setViewControllers([standingsViewController!], animated: true)
Run Code Online (Sandbox Code Playgroud)
代替
vc.setViewControllers([standingsViewController], animated: true)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5505 次 |
| 最近记录: |