tags:

views:

60

answers:

1

I have a UIBarButtonItem that just doesn't want to get disabled. Short version: when I call

[myBarButtonItem setEnabled:NO];

Nothing happens.

myBarButtonItem is an IBOutlet in myVIewController. myViewController has been added as an object to MainWindow in Interface Builder. The myBarButtonItem outlet has been connected to the BarButtonItem, and has the corresponding @syntesize and property lines set.

@property (nonatomic, retain) IBOutlet UIBarButtonItem *myBarButtonItem;

In myViewController.h,

@synthesize myBarButtonItem;

Anyone have an idea why the above setEnabled method has no affect? Thanks!

UPDATE: Fixed it! Don't know why, but apparently the outlet wasn't being set. I used my App Delegate as the parent object for the UIBarButtonItem, and all worked out.

+1  A: 

If your toolbar has an IBOutlet (and you've checked to make sure it's non-nil), try:

[ [ [ myToolBar items ] objectAtIndex: myBarButtonItemIndex ] setEnabled:(NO) ];
hotpaw2