远程重新加载视图
我想知道是否有一种方法可以从另一个选项卡重新加载一个选项卡内的视图控制器。这是我的场景 选项
- 卡控制器有 2 个或更多选项卡
- 选项卡 1 有一个视图控制器,其中包含根据某些条件创建的视图
- 选项卡 2 是一个设置页面,可以更改一些应用程序设置
- 当设置为选项卡 2 已更改?
有没有像标签栏之类的东西->选项卡->视图控制器->重新加载viewDidLoad?
谢谢
I was wondering if there is a way to reload a view controller inside one tab from another tab. This is my scenario
- Tab controller has 2 or more tabs
- Tab 1 has a view controller which has views created based on some conditions
- Tab 2 is a settings page, where some app settings can be changed
- How can i reload content inside tab 1 when settings in tab 2 are changed?
IS there something like tab bar -> tab -> view controller -> reload viewDidLoad?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我解决这个问题的一般方法是通过视图控制器观察到“设置”类型的对象(模型)。在您的情况下,您可以在应用程序委托中初始化它,将其传递给选项卡 1 和选项卡 2 的视图控制器,然后使用 KVO 来观察它。您还可以直接在选项卡 2 的视图控制器中修改它。
您还可以使用 NSNotifcation 向任何想要观察它的视图控制器发出设置更改的信号。
The general way I solve this problem is by having a "Settings"-type object (Model) that is observed by my view controllers. In your case, you'd initialize it in your app delegate, pass it along to the view controllers for Tab 1 and Tab 2, which would then use KVO to observe it. You'd also directly modify it in Tab 2's view controller.
You could also use a
NSNotifcation
to signal a change in the settings to any view controller that wants to observe it.