开发者

Are there any Tab Bar events for notifying when someone hides/shows the Tab Bar?

I have a Nav controller inside a custom subclass of Tab 开发者_开发百科Bar controller that i created.

I want to know from within the (custom) Tab Bar whenever one of the displayed controllers attempts to hide or show the Tab Bar. (for example when pushing a VC that has its hidesBottomBarWhenPushed=YES onto the Nac controller).

In short i want to be notified of events hiding/showing the Tab Bar but could not find anything in Apple's reference. I tried looking at UITabBar, UITabBarDelegate, UITabBarController, and UITabBarControllerDelegate but all seem to only provide functionality related to the tab bar items.

Thanks in advance.


If you are using a tab bar controller, UIKit explicitly states that every navigation controller instance that will be displayed in the tab bar controller's context will be among its viewControllers property. Now every UINavigationController instance has a delegate, which defines a navigationController:willShowViewController:animated: method which lets you know when a view controller is pushed onto it.

By setting your tab bar controller as the delegate of every navigation controller that is pushed onto it, you can analyze wether the view controller being pushed has the hidesBottomBarWhenPushed property set and generate an event when this is the case.

The algorithm used to hide the tab bar controller's tab bar is as follows: when a view controller is pushed on a navigation controller which is itself contained in a tab bar controller, if any view controller in the navigation stack of the navigation controller has the hidesBottomBarWhenPushed property set, then the tab bar should be hidden.

So the tab bar is hidden when a navigation controller is selected and one of the view controllers in its stack have the hidesBottomBarWhenPushed property set.


Subclass UINavigationController and implement the setter behind hidesBottomBarWhenPushed (or subclass the UIViewController to directly subclass the hidesBottomBarWhenPushed method) and delegate the call to the UITabBar (through a direct call or a NSNotification).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜