hidesBottomBarWhenPushed causes tab bar to disappear permanently if the view controller is popped off when a modal is present

Originator:RichWChan
Number:rdar://16095272 Date Originated:18-Feb-2014
Status:Open Resolved:
Product:iOS SDK Product Version:7.0.3
Classification:UI Reproducible:Always
 
Summary:
After pushing a UIViewController with `hidesBottomBarWhenPushed` set to YES, if a modal view controller is present at the time the view controller was popped off of its navigation controller, the tab bar will be permanently hidden.

Steps to Reproduce:
1. Create a UITabBarController with a UINavigationController as one of the tabs
2. Push a view controller with hidesBottomBarWhenPushed set to YES
3. Notice that the tab bar is now hidden
4. Present a view controller as a modal
5. Pop the navigation controller back to root
6. Dismiss the modal view controller
7. Observe that the tab bar is permanently hidden

Expected Results:
The expected behavior would be to have the tab bar return since there is no longer a view controller with hidesBottomBarWhenPushed on the navigation stack.

If you don't present the modal view controller, or if you dismiss it prior to popping the view controller off the stack, the tab bar will be visible as expected.

Actual Results:
As mentioned above, the tab bar will be permanently hidden. Pushing view controllers with hidesBottomBarWhenPushed set to NO will not bring it back either.

Sample screen recordings:
https://www.dropbox.com/s/6gr4wg8vz1s6k5p/hidesbottombar-bug.mov
Recording of the expected results (where the modal is dismissed before popping off the view controller):
https://www.dropbox.com/s/x7wh4of2axxb78e/hidesbottombar-expected.mov

Version:
The bug has been observed when testing against iOS 7.0.3 and iOS 7.1-beta4.


Attached sample code: (create a new project and replace the app delegate's didFinishLaunchingWithOptions method)
```
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.

    // start with any stack of view controllers in a tab bar controller
    UINavigationController *nav = [[UINavigationController alloc] init];
    nav.viewControllers = @[
                            [UIViewController new],
                            [UIViewController new],
                            ];
    nav.title = @"hello";
    UITabBarController *tabBarController = [[UITabBarController alloc] init];
    tabBarController.viewControllers = @[ nav ];

    self.window.rootViewController = tabBarController;

    __block UIViewController *presented;

    NSArray *ops = @[
    ^{
        // push a hide bottom bar view controller
        UIViewController *vc = [UIViewController new];
        vc.view.backgroundColor = [UIColor blueColor];
        vc.hidesBottomBarWhenPushed = YES;
        [nav pushViewController:vc animated:YES];
    },
    ^{
        // present a modal
        presented = [UIViewController new];
        presented.view.backgroundColor = [UIColor redColor];
        [[[nav viewControllers] lastObject] presentViewController:presented animated:YES completion:nil];
    },
    ^{
        // pop nav stack to root
        [nav popToRootViewControllerAnimated:YES];
    },
    ^{
        // dismiss modal
        [[presented presentingViewController] dismissViewControllerAnimated:YES completion:nil];
    },
    ^{
        // push another view controller
        UIViewController *vc = [UIViewController new];
        vc.view.backgroundColor = [UIColor greenColor];
        [nav pushViewController:vc animated:YES];
    }
     ];

    [ops enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
        void(^blk)() = obj;

        dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 + 2.0 * idx * NSEC_PER_SEC));
        dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
            blk();
        });
    }];

    self.window.backgroundColor = [UIColor whiteColor];
    [self.window makeKeyAndVisible];
    return YES;
}
```

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!