gpt4 book ai didi

iphone - 在 iOS 中从 topViewController 向 rootViewController 发送消息

转载 作者:行者123 更新时间:2023-12-01 19:15:30 24 4
gpt4 key购买 nike

我正在为 iPhone 开发一个应用程序,我需要从 topViewController 发送消息至rootViewController .

一种解决方案可能是在导航堆栈中的每个 VC 中创建委托(delegate)方法并相应地调用,以便消息将到达 rootViewController。 .但在这种情况下,消息必须通过整个导航堆栈。

任何机构都可以用最好的方法帮助我吗

谢谢

最佳答案

一种选择是访问 rootViewcontroller作为,

RootViewController *rootViewController = (RootViewController *)[self.navigationController.viewControllers objectAtIndex:0];

然后对这个对象做必要的操作。 navigationController.viewControllers返回导航堆栈中的所有 View Controller 。

关于iphone - 在 iOS 中从 topViewController 向 rootViewController 发送消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13720153/

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