A quite useful button for a navigation controller with a deep stack would be a home button. It is simple to add.
In your RootViewController viewDidLoad Function
- (void)viewDidLoad {
[super viewDidLoad];
UIBarButtonItem *homeButton = [[[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Home", @"") style:UIBarButtonItemStyleBordered target:self action:@selector(goHome:)] autorelease];
self.navigationItem.rightBarButtonItem = homeButton;
}
[super viewDidLoad];
UIBarButtonItem *homeButton = [[[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Home", @"") style:UIBarButtonItemStyleBordered target:self action:@selector(goHome:)] autorelease];
self.navigationItem.rightBarButtonItem = homeButton;
}
That will add a home button in to top right of your navigation controller
Create a function called go home in your rootViewController
// return to root view
- (void)goHome:(id) sender {
[self.navigationController popToRootViewControllerAnimated:YES];
}
- (void)goHome:(id) sender {
[self.navigationController popToRootViewControllerAnimated:YES];
}
This function will pop your view controller to its root view