How to restore back button function in UINavigationController?

I created my own leftBarButtonItem:

UIBarButtonItem* homeButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks 
                                                                                    target:self 
                                                                                    action:@selector(homeButtonClicked:)];

self.navigationItem.leftBarButtonItem = homeButton;

How can I programmatically restore the back button to its original functionality?

+5
source share
3 answers

The back button invokes UINavigationController popViewController, so you can replicate it to the selector homeButtonClicked:.

-1
source
self.navigationItem.leftBarButtonItem = self.navigationItem.backBarButtonItem;
+36
source
self.navigationItem.leftBarButtonItem = nil;

, .

+2

All Articles