views:

199

answers:

2

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.

+1  A: 

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

Ray Wenderlich
+1  A: 

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.

iamiPhone