gpt4 book ai didi

Swift:在带有委托(delegate)的模态视图上显示导航栏/顶部栏

转载 作者:行者123 更新时间:2023-11-28 08:34:40 28 4
gpt4 key购买 nike

我试图强制导航栏显示在模态视图上。根据 this answer ,我试图通过在一个特殊的导航 Controller nextScreenNavigationController 中嵌入模态视图 nextScreenViewController 来做到这一点。

但是,我使用委托(delegate)模式在初始 viewController 和 nextScreenViewController 之间传递数据。在嵌入 navigationController 之前,我使用以下代码进行了初始化:

override func prepareForSegue(segue: UIStoryboardSegue, sender:   AnyObject?) {
if segue.identifier == "goToNextScreen" {
let nextScreenDelegate = segue.destinationViewController as! nextScreenViewController
nextScreenDelegate.delegate = self
}
}

Some research建议,为了说明 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
}
}

但是,没有崩溃就失败了——没有数据被传递。

如果您想要更多我的委托(delegate)模式,请发表评论...我只是想确定这不是一个基本的实现问题。或者,是否有更好的方式在模态视图上显示导航栏?

最佳答案

对不起 - 没关系!我意识到上面的代码有效,我的问题是我未能在 Storyboard 中为 navigationController 分配类 nextScreen NavigationController

关于Swift:在带有委托(delegate)的模态视图上显示导航栏/顶部栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38146930/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com