gpt4 book ai didi

ios - 使用定义的协议(protocol)将 UINavigationController 功能添加到容器 Controller

转载 作者:行者123 更新时间:2023-11-29 11:03:59 24 4
gpt4 key购买 nike

我设计了一个自定义容器 View Controller ,它模仿路径或 facebook 等功能(滑动平台效果)。为了与这些 Controller 通信,我定义了一个协议(protocol),允许向他们询问一些信息/提醒他们一些事件。

现在,我决定将其中一个 subview Controller 嵌入到导航 Controller 中。不幸的是,导航 Controller 现在正在接收这些协议(protocol)方法,我遇到了崩溃。

我的临时解决方案是创建一个中间方法,询问我要与之交谈的 Controller 是否实际上是导航 Controller ,如果是,则将消息发送到根。

有没有更优雅的方式来做到这一点?似乎代码味道必须编写一个“介于两者之间”的方法来对我的基本 Controller 中的每个协议(protocol)方法执行此检查。有什么想法吗??

谢谢

最佳答案

您是否尝试过将父 View Controller 而不是特定的子 Controller 嵌入到 NavigationController 中?通过这样做,您可以有效地允许所有子 Controller 参与导航。这将使您能够正确使用您的协议(protocol)。

关于ios - 使用定义的协议(protocol)将 UINavigationController 功能添加到容器 Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14513017/

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