将消息从根视图控制器传递到另一个视图控制器
我有一个导航根视图控制器,我将其推送到另一个视图控制器。
视图控制器将根据根视图控制器中按下的按钮来确定第三个推送的控制器。基于此,我如何通过委托从根视图控制器向第二个视图控制器 2 发送消息,表明按钮 1 或按钮 2 已被按下?
I have a navigation root view controller, which I am pushing to another view controller.
The view controller will determine the third pushed controller based on what button was pressed in root view controller. Based on this, how can I send a message through delegate from the root view controller to the second view controller 2 that either button 1 or button 2 has been pressed?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果差异是应用程序状态的更改,请在应用程序委托上创建一个属性,或创建一个管理器类来处理应用程序状态。当您触摸根视图控制器中的按钮时设置属性/通知管理器,然后在加载第三个视图控制器时检查此值。
如果区别仅仅是导航到应用程序的不同区域,请在第二个视图控制器和第三个视图控制器上创建一个属性。当您触摸根视图控制器中的按钮时,请在第二个视图控制器上设置该属性。当您从第二个视图控制器导航到第三个视图控制器时,请先在第三个视图控制器上设置属性,然后再将其推入堆栈。
If the difference is a change in state for the application, either create a property on your application delegate, or create a manager class to handle your application state. Set the property / notify the manager when you touch the button in your root view controller, then check this value when your third view controller loads.
If the difference is merely that are navigating to a different area of the app, create a property on your second view controller and your third view controller. When you touch the button in your root view controller, set the property on the second view controller. When you navigate from the second view controller to the third view controller, set the property on the third view controller before you push it onto the stack.