1
votes

I have a UITabBarController root view controller with three view controllers, once of which is a UINavigationController with a UIViewController containing a UISearchDisplayController and a UITableView. The UINavigationController toolbar is not hidden.

However, when I select a row in the UITableView, I would like to push another UIViewController. When this UIViewController is pushed, the UINavigationController toolbar should slide out and the UITabBarController tab bar should remain visible.

I tried setting the hidesBottomBarWhenPushed property of the pushed UIViewController to true (which provides the intended behavior when the UINavigationController is not nested within a UITabBarController). Unfortunately, rather that sliding the UINavigationController toolbar out when hidesBottomBarWhenPushed is set to true, the UITabBarController slides out, leaving the UINavigationController visible in the pushed UIViewController as the bottom bar.

How might slide out the UINavigationController toolbar when pushed, and not the UITabBarController tab bar?

EDIT #1: The only possible solution I can think of is, rather than using the UINavigationController toolbar, simply add a UIToolbar to the bottom of the UIViewController view containing the UITableView. This will assure that the UIToolbar slides out when the new UIViewController is pushed and slides in when the new UIViewController is popped. The only problem is, for the iPhone and iPod Touch, unlike the UINavigationController toolbar, the height of a UIToolbar instance (44 pixels) will not shrink to 30+ pixels in height (like the UINavigationController toolbar does) when the device is rotated in to a landscape orientation. If this is the only legitimate solution, how might I change the height of a UIToolbar to match the height of the UINavigationController toolbar in landscape?

EDIT #2: Regarding EDIT #1, I suppose the frame of the UIToolbar could be changed in the willRotateToInterfaceOrientation method. I would still like to find a solution for sliding out the UINavigationController toolbar, though. Better than creating a separate UIToolbar for every UIViewController I wish have a bottom toolbar.

EDIT #3: Basically, here is what I have (this is the result of hidesBottomBarWhenPushed): http://flic.kr/p/bcjydn

And, here is what I would like to achieve: http://flic.kr/p/bcjybK

EDIT #4: Firstly, thank you for your time. Secondly, unfortunately, the setToolbarHidden:animated: method in UINavigationController is unable to produce the slide out/slide in animations as seen with setHidesBottomBarWhenPushed: (refer to the links in EDIT #3, specifically the second link, for the desired animation). For example, assume we write:

- (void)viewWillAppear:(BOOL)animated
{
    [self.navigationController setToolbarHidden:NO animated:NO];
    [super viewWillAppear:animated];
}

in the parent view controller (the view controller in which the toolbar is not hidden), and assume we write:

- (void)viewWillAppear:(BOOL)animated
{
    [self.navigationController setToolbarHidden:YES animated:NO];
    [super viewWillAppear:animated];
}

in the child view controller (the view controller in which the toolbar is hidden).

As soon as we push the child view controller on to the UINavigationController stack from the parent view controller, the child view controller viewWillAppear: method will be called. This will simply hide the UINavigationController toolbar (before the push animation starts), exposing the portion of the UIWindow that lies beneath the UINavigationController toolbar. The remainder of the push animation executes as expected (UINavigationController toolbar still not visible in the child view controller, everything resized appropriately). Then, when we pop the child view controller, the viewWillAppear: method will be called for the parentViewController, which will unhide the UINavigationController toolbar (making the toolbar visible in the child view controller), then the pop animation will execute. The remainder of the pop animation executes as expected (UINavigationController toolbar still visible in the parent view controller, everything resized appropriately).

Kind of figured this question was going to lead down a rathole. The only remaining ideas I have are:

1) EDIT #1 (though that implementation is limited by the inability to appropriately or legally alter the height of a standard UIToolbar instance an iPod Touch or iPhone is in landscape; one reason why I am hellbent on using the UINavigationController's toolbar).

2) Either subclass UITabBar or UITabBarController to try to prevent the setHidesBottomBarWhenPushed: method from realizing that the UITabBarController tab bar is the bottom bar. Basically, bypass the tab bar and pass the UINavigationController toolbar instead. Probably the most promising idea, but potentially the most difficult (as the knowledge of the setHidesBottomBarWhenPushed: innards is limited, and since private APIs might be required).

2
what you want to hide or what you show in next screen? if possible show codeHiren
I added EDIT #3 to my post. This will give you an idea of what I have right now (using setting hidesBottomBarWhenPushed to YES for the UIViewController I am drilling down to). And, it will give you an idea of what I would like to achieve. I am beginning to think that EDIT #1 may be the easiest solution. But, it is also the bulkiest solution. Not to mention, to resize the height of a UIToolbar instance (like the UINavigationController toolbar), you need to set the autoResizingMask or the frame for the toolbar, both of which don't seem to be suggested by the HIG.Nicholas Peters

2 Answers

3
votes

when you push your navigation bar controller write the code like

YourController = [[YourController alloc] initWithNibName:@"YourController" bundle:nil]
controller.hidesBottomBarWhenPushed = TRUE;
[self.navigatoinController pushViewController:controller Animated:YES];

//// Try this code where you want to hide navigation bar

-(void)viewWillAppear{
    self.navigationController.navigationBarHidden = TRUE;
}
0
votes

In your UIViewController's method viewWillAppear make the following call

[self.navigationController setToolbarHidden:YES animated:NO];

That bar belong the the UINavigationController. While I've never used hidesBottomBarWhenPushed it look like it's going for the most bottom bar it can find.