iamMobile
iamMobile

Reputation: 969

How to disable rightBarButtonItem

How can I enable/disable navigationItem.rightBarButton item? I am calling the following code at -viewDidLoad but it does nothing.

self.navigationItem.rightBarButtonItem = 
      [[[UIBarButtonItem alloc]
            initWithTitle:@"Flow"
            style:UIBarButtonItemStyleDone
            target:self  action:@selector(flowWithMe:)] autorelease];

self.navigationItem.rightBarButtonItem.enabled = NO;

I want to enable right Bar Button only on a particular action.

Upvotes: 2

Views: 3825

Answers (2)

iamMobile
iamMobile

Reputation: 969

I found the problem, i was reenabling the button on - (void)textFieldDidBeginEditing:(UITextField *)textField

and this was the only text field on the view and on ViewDidLoad this was becoming the first responder so after ViewDidLoad, this function was getting called and right bar button was re-enabled.

Upvotes: 2

Ray Wenderlich
Ray Wenderlich

Reputation: 480

You can set the rightBarButtonItem to nil until the point where you need to enable it.

Upvotes: 2

Related Questions