Swift:使用代理在模式视图上显示导航栏/顶栏
我试图强制导航栏在模式视图上显示。根据,我正试图通过将模态视图,Swift:使用代理在模式视图上显示导航栏/顶栏,swift,uinavigationcontroller,modal-dialog,uikit,Swift,Uinavigationcontroller,Modal Dialog,Uikit,我试图强制导航栏在模式视图上显示。根据,我正试图通过将模态视图,nextScreenViewController嵌入一个特殊的导航控制器,nextscreenvigationcontroller来实现这一点 但是,我使用代理模式在初始viewController和nextScreenViewController之间传递数据。在嵌入navigationController之前,我使用以下代码进行初始化: override func prepareForSegue(segue: UIStoryboa
nextScreenViewController
嵌入一个特殊的导航控制器,nextscreenvigationcontroller
来实现这一点
但是,我使用代理模式在初始viewController和nextScreenViewController
之间传递数据。在嵌入navigationController之前,我使用以下代码进行初始化:
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "goToNextScreen" {
let nextScreenDelegate = segue.destinationViewController as! nextScreenViewController
nextScreenDelegate.delegate = self
}
}
建议,为了解释nextScreenNavigationController
我应该使用如下代码
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "goToNextScreen" {
let navigation: UINavigationController = segue.destinationViewController as! nextScreenNavigationController
var nextScreenDelegate = nextScreenViewController.init()
nextScreenDelegate = navigation.viewControllers[0] as! nextScreenViewController
nextScreenDelegate.delegate = self
}
}
但是,如果没有崩溃,则会失败-不会传递任何数据
如果您想了解更多我的委托模式,请发表评论。。。我只是想确定这不是一个基本的实现问题。或者,有没有更好的方式在模式视图上显示导航栏?对不起-没关系!我意识到上面的代码是有效的,我的问题是我没有在故事板中将类
nextScreenNavigationController
分配给navigationController。对不起-没关系!我意识到上面的代码是有效的,我的问题是我没有在故事板中将类nextScreenNavigationController
分配给navigationController