Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Observe when UITabBar is Hidden from Delegate

How do I add an observer for when a UITabBar is hidden (through 'hides-bottom-bar-when-pushed')? I have a custom button that sits underneath my tab bar and I want to make sure it doesn't appear when the UITabBar is hidden. Thanks!

like image 415
Stussa Avatar asked Oct 11 '22 20:10

Stussa


2 Answers

Try using the UINavigationControllerDelegate protocol:

- (void)navigationController:(UINavigationController *)navigationController 
      willShowViewController:(UIViewController *)viewController
                    animated:(BOOL)animated
{
    if (viewController.hidesBottomBarWhenPushed) {
        // ...
    }
}
like image 95
Wilbur Vandrsmith Avatar answered Oct 14 '22 01:10

Wilbur Vandrsmith


The best option is to place your UIToolbar inside a UIView that has clipping enabled and position the clip-view just above the UITabBar. Then add this UIView as a subview of your UITabBar. This way showing and hiding the UITabBar will automatically show or hide your UIToolbar Now you can animate the showing and hiding of your UIToolbar and still have it disappear each time the UITabBar does.

like image 35
Kevin Sylvestre Avatar answered Oct 14 '22 03:10

Kevin Sylvestre