Watch when the UITabBar is hidden from the delegate

How to add an observer when the UITabBar is hidden (via "hides-bottom-bar-when-push")? I have a custom button that is under my tab bar, and I want to make sure that it does not appear when the UITabBar is hidden. Thanks!

+4
source share
3 answers

The best option is to place the UIToolbar inside the UIView with clipping enabled and position the clip just above the UITabBar . Then add this UIView as a subtitle of your UITabBar . This way of showing and hiding the UITabBar will automatically show or hide your UIToolbar Now you can animate the show and hide of your UIToolbar and still disappear every time the UITabBar is UITabBar .

+1
source

Try using the UINavigationControllerDelegate protocol :

 - (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated { if (viewController.hidesBottomBarWhenPushed) { // ... } } 
+4
source

This will tell you when the value of this field changes:

  UITabBar *myTabBar = [[UITabBar alloc] init]; [self addObserver:myInterestedObjectWhoWantsToKnowWhenTabBarHiddenChanges forKeyPath:@"myTabBar.hidesBottomBarWhenPushed" options:NSKeyValueObservingOptionNew context:nil]; 

Then in myInterestedObjectWhoWantsToKnowWhenTabBarHiddenChanges.m we implement

  - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { if ([keyPath isEqualToString:@"myTabBar.hidesBottomBarWhenPushed"]) { // this key must match, where observer is set. // object will be "self" from the code above // and the change dictionary will have the old and new values. } } 
-1
source

All Articles