I hope t开发者_如何学Goo access UIBarButtonItem on an UIToolbar using tag. The codes show below
UIBarButtonItem *myBarButtonItem=(UIBarButtonItem*)myUIToolBar.items[i];
but myBarButtonItem returns no object(0x0)
Here is the documentation from Apple:
The items displayed on the toolbar.
@property(nonatomic, copy) NSArray *items Discussion The items, instances of UIBarButtonItem, that are visible on the toolbar in the order they appear in this array. Any changes to this property are not animated. Use the setItems:animated: method to animate changes.
The default value is nil
Did you set the items array, can you print out the value of NSLog(@"%@", myToolBar.items);
to see if it is nil and to see how many UIBarButtonItem inside
精彩评论