Reputation: 73
I use in my application a tabbar controller and under the first tab is a navigationcontroller.
The rootview of the navigation controller stack shows a searchbar to the user, where he can input text. after finishing with his input, the user starts some search service of our site. During the search performing I want to show some "status information", so I push another viewcontroller (statusInfoController
) on the navigationcontroller's stack.
After the search has finished (this takes up to 10s), the result table controller is pushed to the navigation controllers stack.
Now I want to show some back button in the uinavigationbar
, which takes the user back to the root view controller. I did the following in the viewWillAppear
-method of the result table controller:
UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle:@"Zurück21"
style:UIBarButtonItemStyleBordered
target:self
action:@selector(popBackToFirstView)];
self.navigationItem.leftBarButtonItem = backButton;
UIBarButtonItem *backButton2 = [[UIBarButtonItem alloc] initWithTitle:@"Zurück22"
style:UIBarButtonItemStylePlain
target:nil
action:nil];
self.navigationItem.backBarButtonItem = backButton2;
self.navigationItem.title = [self.lastSearch suchAnfrage];
[backButton release];
backButton = nil;
[backButton2 release];
backButton2 = nil;
and I implemented the popBackToFirstView
-method in this class. There is also this second UIBarButtonItem
assign to the backBarButtonItem
property for the detailView
(which is pushed to the navigationController's stack when the user touches some entry in the resulttableview).
My problem: all back-buttons which come from self.navigationItem.backBarButtonItem
are with an arrow on the left side, but the button assigned to self.navigationItem.leftBarButtonItem
is a normal button, no arrow.
How can I add an arrow to the "special" back button? Which style should I use?
Or should I use standard back buttons? But then, there must be any other way to "hop" over the statusInfoController-View?
Upvotes: 0
Views: 2055
Reputation: 17861
You're looking for the wrong sort of solution.
The real problem is your approach of pushing extra controllers onto the navigation stack—you should never push anything onto the stack unless it's something that the user would want to navigate back to. Rework your code to show the status display and search results in the same view controller as the search bar. Take a close look at how built-in apps like the iTunes Store do searching and try to duplicate their behavior.
Upvotes: 1
Reputation: 11476
I think the back arrow feature is an integrated part of letting the SDK control your use of the navigation bar.
The only solution - if you could call it so - would be to write your own custom navigation bar class, as a subclass of UIViewController (use a NIB to make it easier still) and then you'd have all the flexibility you could want.
Upvotes: 0