Back Navigation Button Not Showing up in Pushed View Controller

Paul Ward picture Paul Ward · Aug 6, 2010 · Viewed 10.7k times · Source

I have a problem where I can successfully push a new view controller from my root view controller (using the Navigation-based application using Core Data template), but the detail view, which is a separate xib file from the root view controller, doesn't display the back navigation button. I'm certain that I've done all of the proper connections in IB, and everything else is working as expected.

RootViewController.h

@class ItemsViewController;

@interface RootViewController : UITableViewController <NSFetchedResultsControllerDelegate> {

IBOutlet ItemsViewController *itemsVC;

}

@property (nonatomic, retain) IBOutlet ItemsViewController *itemsVC;

@end

RootViewController.m

#import "ItemsViewController.h"

@synthesize itemsVC;

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{
// Pushes to ItemsViewController

ItemsViewController *itemsViewController = [[ItemsViewController alloc] initWithNibName:@"ItemsViewController" bundle:[NSBundle mainBundle]];

[self.navigationController pushViewController:itemsViewController animated:YES];
[itemsViewController release];

}

ItemsViewController is a UITableViewController subclass with its own xib, also named ItemsViewController. Again, it gets pushed from RootViewController, but the back button doesn't show up like this. I was under the impression that it was a "free" feature of using a navigation controller. As you might expect, this is a very frustrating roadblock and I would appreciate any help.

Answer

Shaggy Frog picture Shaggy Frog · Aug 6, 2010

Does your ItemsViewController class set its title property in its viewDidLoad method?

You should call [tableView deselectRowAtIndexPath:indexPath animated:YES] as the last line of tableView:didSelectRowAtIndexPath: to conform to Apple's human interface guidelines.