远程重新加载视图

发布于 2024-10-06 22:01:09 字数 261 浏览 0 评论 0原文

我想知道是否有一种方法可以从另一个选项卡重新加载一个选项卡内的视图控制器。这是我的场景 选项

  1. 卡控制器有 2 个或更多选项卡
  2. 选项卡 1 有一个视图控制器,其中包含根据某些条件创建的视图
  3. 选项卡 2 是一个设置页面,可以更改一些应用程序设置
  4. 当设置为选项卡 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

  1. Tab controller has 2 or more tabs
  2. Tab 1 has a view controller which has views created based on some conditions
  3. Tab 2 is a settings page, where some app settings can be changed
  4. 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

归途 2024-10-13 22:01:09

我解决这个问题的一般方法是通过视图控制器观察到“设置”类型的对象(模型)。在您的情况下,您可以在应用程序委托中初始化它,将其传递给选项卡 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文