如何在具有导航的 Tabbar 应用程序中调用 viewWillDisappear 方法 [英] How to call viewWillDisappear method in Tabbar Application having navigations also

查看:22
本文介绍了如何在具有导航的 Tabbar 应用程序中调用 viewWillDisappear 方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的应用程序中创建了 5 个标签.在 Tab1 我有 UITableView.在 didSelectRowAtIndexPath 上,我导航到另一个 UIView,其中显示了我的所有 5 个选项卡.我还在导航视图中播放歌曲.

现在,当我单击导航中的返回按钮并再次转到原始视图时,我可以调用 viewWillDisappear(如预期和正常情况).

但是当我直接单击另一个选项卡时,不会在导航视图中调用 viewWillDisappear.为什么会这样??

我只是想,当我直接点击另一个 Tab 时,Tab1 中的视图将调用 viewWillDisappear.但是导航视图不会调用该方法.

那么可能的解决方案是什么??请给一些提示...

解决方案

我认为您需要在选项卡之间切换时捕捉事件.当您从 Tab1 切换到 Tab2 时,如您所料,Tab1viewWillDisappear 不会被调用.相反,将调用 Tab2viewWillAppear.

否则,如果您想在切换标签时捕捉事件,请检查 这个链接.

I have created 5 Tabs in my application. In Tab1 i have UITableView. On didSelectRowAtIndexPath i am navigating to another UIView in which I am showing my all 5 Tabs. And I also play song in that navigated view.

Now when I click Back button in navigation and i again go to my original view, i am able to call viewWillDisappear (as expected and normal situation).

But when I click directly another tab then viewWillDisappear is not called in the navigated View. Why this Happens??

I have just thought in a way that when I directly clicks the another Tab then the view in Tab1 will call viewWillDisappear. But the navigated view will not call that method.

So what could be possible solutions?? kindly give some hints...

解决方案

I think that you need to catch the event when you switch between tabs. When you switch from Tab1 to Tab2, as you expect, viewWillDisappear of Tab1 will not be called. Instead, the viewWillAppear of Tab2 will be called.

Else if you want to catch the event when you switch tabs, check this link.

这篇关于如何在具有导航的 Tabbar 应用程序中调用 viewWillDisappear 方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆