Hide UINavigationBar LeftBarButtonItem & add custom UIButton in iOS 4.3 and iOS 5.1


You can easily hide the UINavigationBar LeftBarButton. But the problem is your way may not work for both iOS 4.3 & iOS 5.1.

I just find a way that work in both iOS

Code is:

self.navigationController.navigationItem.leftBarButtonItem =nil;

You can also hide the navigation bar buttons using

self.navigationItem.leftBarButtonItem =nil;

But this will work only for iOS 5.1 not for iOS 4.3.

Instead of showing this button if you want to add your custom button add the following code:

UIBarButtonItem *settingsButton = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"bottom-setting-act_iPad.png"] style:UIBarButtonItemStyleDone target:self action:@selector(settingsButtonClicked:)];
self.navigationItem.leftBarButtonItem= settingsButton;

settingsButtonClicked is the function that will be called when button will be clicked.

Thanks.

Advertisements

About Razib Chandra Deb

I completed my BSc in CSE from CSE Department of KUET. Currently I am working as a Software Engineer in Samsung R&D Institute Bangladesh(SRBD). I am interested in image processing.
This entry was posted in Uncategorized and tagged , , , , , . Bookmark the permalink.

2 Responses to Hide UINavigationBar LeftBarButtonItem & add custom UIButton in iOS 4.3 and iOS 5.1

  1. Harold says:

    I need to to thank you for this wonderful read!! I certainly
    loved every bit of it. I have got you book marked to check out new stuff you post…

  2. Pingback: Monica Sadorra

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s