什么方法用于识别用户何时在选项卡视图控制器中切换视图

发布于 2024-09-06 19:33:51 字数 230 浏览 1 评论 0原文

我正在开发我的第一个简单的选项卡视图控制器应用程序。第一个选项卡是设置选项卡,我刚刚让测试人员提供了一个意外的用例。为了解决这个用例,我需要在用户离开视图时和加载下一个视图之前执行。在下一个视图中运行代码为时已晚。

当用户选择 TabView 控制器来切换视图时,从当前 viewController 调用什么方法?

我尝试使用 viewWillDisappear 作为执行代码的点,但是切换视图时似乎不会调用它。

I am working on my first simple tabview controller app. The first tab is a setup tab, and I just had a tester provide an unexpected use case. In order to address this use case, I need to execute when the user is leaving the view and before I load the next one. Running code in the next view is too late.

What method is called from the current viewController at the point the user selects the TabView Controller to switch views?

I've tried using viewWillDisappear as the point to execute my code, but this does not appear to be called when switching views.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

季末如歌 2024-09-13 19:33:51

好吧,必须重构代码以消除依赖关系。已决定存储每个屏幕元素的状态,然后在需要时在辅助视图上访问它。

OK, had to restructure the code to remove the dependency. Have decided to store the state of each screen element and then access it when needed on the secondary view.

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