Reputation: 335
I have a project where I use a NavigationController
as a detailed view for my SplitViewController
.
So when the app shows up, everything is fine in both orientations. However as soon as i push a view inside my navigation controller, if i'm in portrait mode my button to 'show master view' (uisplitview delegate) will disapear and the 'back' button of the uinavigationcontroller
will replace it. If i press the back button to pop my view, the 'show master view' button comes back.
My question is, how do i manage the fact that i want to be able to show both buttons ('back', 'show master') in my UINavigationBar
even if i have pushed some views?
Upvotes: 0
Views: 228
Reputation: 447
You can do it with a UIToolbar. You must first hide the navigationbar and place a UiToolbar on the top of the view.
Now you can add as buttons as you want.
UIToolbar *tools = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 20, 1036, 42)];
tools.barStyle = UIBarStyleBlackTranslucent;
NSMutableArray* buttons = [[NSMutableArray alloc] initWithCapacity:3];
UIBarButtonItem * backButton = [[UIBarButtonItem alloc] initWithCustomView:myCustomView];
[buttons addObject:backButton];
//you can add also a spacer
UIBarButtonItem *spacer = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
[buttons addObject:spacer];
UIBarButtonItem * homeButton = [[UIBarButtonItem alloc] initWithCustomView:myCustomView];
[buttons addObject:homeButton];
[tools setItems:buttons animated:NO];
Upvotes: 1
Reputation: 9355
You simply can't do that with a regular UINavigationBar
.
You'd have to place your "show master view" button somewhere else - e.g. in a UIToolbar
at the bottom of your detail view.
Or you could code your own NavigationController and NavigationBar, but that's a bit more work. :)
Upvotes: 0