但是当我直接单击另一个选项卡时,不会在导航视图中调用 viewWillDisappear.为什么会这样??我只是想,当我直接点击另一个 Tab 时,Tab1 中的视图将调用 viewWillDisappear.但是导航视图不会调用该方法.那么可能的解决方案是什么??请给一些提示... 解决方案 我认为您需要在选项卡之间切换时捕捉事件.当您从 Tab1 切换到 Tab2 时,如您所料,Tab1 的 viewWillDisappear 不会被调用.相反,将调用 Tab2 的 viewWillAppear.否则,如果您想在切换标签时捕捉事件,请检查 这个链接.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 方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-19 01:34