Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I restore the back button functionality in UINavigationController?

I have created my own leftBarButtonItem:

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

self.navigationItem.leftBarButtonItem = homeButton;

How can I restore the original back button functionality programmatically?

like image 570
Sheehan Alam Avatar asked Jun 16 '10 14:06

Sheehan Alam


2 Answers

self.navigationItem.leftBarButtonItem = self.navigationItem.backBarButtonItem;
like image 106
heMac Avatar answered Sep 29 '22 07:09

heMac


self.navigationItem.leftBarButtonItem = nil;

This will remove your custom left button, and the back button will appear again.

like image 41
TotoroTotoro Avatar answered Sep 29 '22 06:09

TotoroTotoro