views:

38

answers:

2

I came across a very subtle issue.

Usually things are okay, but occasionally the current UIviewController has no title. When I call another viewcontroller called via

[[fruitDB navigationController] pushViewController:fruitc animated:YES];

there is no "back" button. The area on the top left of the navigation bar is still active though and I can go back.

How can I make sure the back button is still active, even if there is no title?

A: 

Just before you push the next view controller why don't you try: self.title = @"Back";??

Thomas Clayson
When you come back the title is wrong.
John Smith
then add in "viewWillAppear" `self.title=@"";`
Thomas Clayson
+1  A: 

you can set the backBarButtonItem of the navigation item of the view controller.

Specifically, somewhere in viewController1 before pushing viewController2, do the following...

self.navigationItem.backBarButtonItem = [[[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStylePlain target:nil action:nil] autorelease];

When you push viewController2, the back button shown will be the backBarButtonItem of viewController1.

Note: Technically, apple recommends overriding the navigationItem method in your view controller, and adding buttons there, but it's really not an issue in your case.

Jerry Jones