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
0 comments ↓
If you found this post useful click the share this button. Contribute below by adding a comment, no registration is required.
DCE Related Posts
One of my CoreData applications started acting buggy, and was spitting out a huge error dump on app close in the debug console. Read Full Article...
A function that validates user has inputted text into the UITextField and executes a submission function on the iPhone using Xcode on Required Fields Read Full Article...
Comparing strings in the iPhone SDK with UITextfield values Read Full Article...
There are no comments yet...Kick things off by filling out the form below.
Leave a Comment