【发布时间】:2015-09-10 21:36:59
【问题描述】:
我在 Swift 中使用 SWRevealViewController 并为左侧导航构建了一个动态 UITableView 以加载菜单选项。根据用户选择的 didSelectRowAtIndexPath,然后我尝试使用
加载新的 ViewControllerself.revealViewController().pushFrontViewController(<<name_of_new_view_controller>>(), animated: true)
在新的视图控制器中,在 viewDidLoad() 下,我有以下代码:
if self.revealViewController() != nil {
menuButton.target = self.revealViewController()
menuButton.action = "revealToggle:"
}
然而,当这个视图加载时,我得到一个错误:
致命错误:在展开可选值时意外发现 nil
有问题的项目是 nil,实际上是 menuButton,它是一个 Bar Button Item(它是显示/隐藏侧导航菜单的汉堡按钮)。
任何想法为什么这不起作用?这一切都是从我的故事板到我的班级的一个出口。
【问题讨论】:
标签: ios swift swrevealviewcontroller