Removing right bar button item from navigation item

Abhinav picture Abhinav · May 24, 2011 · Viewed 25.6k times · Source

I have added a right bar button item in my navigation item and want to remove this on some condition. This is what I am doing:

self.navigationItem.rightBarButtonItem = nil;

But not getting the desired behavior.

I want to hide it but do not find any method for it.

Answer

Erik B picture Erik B · May 24, 2011

What you're doing should work. I've done that lots of times. Are you sure you're removing the button from the correct navigation item? Is self the currently displayed UIViewController?