tags:

views:

15

answers:

1

Hello everyone I hope to access UIBarButtonItem on an UIToolbar using tag. The codes show below

UIBarButtonItem *myBarButtonItem=(UIBarButtonItem*)myUIToolBar.items[i];

but myBarButtonItem returns no object(0x0)

Welcome any comment

Thanks

interdev

A: 

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

vodkhang