Sheehan Alam
Sheehan Alam

Reputation: 60919

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?

Upvotes: 6

Views: 2112

Answers (3)

TotoroTotoro
TotoroTotoro

Reputation: 17622

self.navigationItem.leftBarButtonItem = nil;

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

Upvotes: 4

heMac
heMac

Reputation: 1539

self.navigationItem.leftBarButtonItem = self.navigationItem.backBarButtonItem;

Upvotes: 38

pgb
pgb

Reputation: 25011

The back button will call UINavigationController's popViewController, so you can replicate that on your homeButtonClicked: selector.

Upvotes: -1

Related Questions