Is it possible to access a UIBarButtonItem using a tag?

I hope to access the UIBarButtonItem on the UIToolbar using the tag. Cheats below

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

but myBarButtonItem does not return an object (0x0)

+3
source share
1 answer

Here is the documentation from Apple:

Items displayed on the toolbar.

@property (non-atomic, copy) NSArray * items Discussion Elements, instances of UIBarButtonItem that are visible on the toolbar in the order in which they appear in this array. Any changes to this property are not animated. using setItems: animated: method animated changes.

The default value is nil

, NSLog(@"%@", myToolBar.items);, , nil , UIBarButtonItem

0

Source: https://habr.com/ru/post/1767630/


All Articles