是否可以使用标签访问UIBarButtonItem? [英] Is it possible to access UIBarButtonItem using tag?

查看:43
本文介绍了是否可以使用标签访问UIBarButtonItem?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望使用标签访问UIToolbar上的UIBarButtonItem.代码如下所示

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

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

但是myBarButtonItem不返回任何对象(0x0)

but myBarButtonItem returns no object(0x0)

推荐答案

以下是Apple提供的文档:

Here is the documentation from Apple:

工具栏上显示的项目.

The items displayed on the toolbar.

@property(非原子的,副本)NSArray*项目讨论可见的项目,UIBarButtonItem的实例在工具栏上的顺序出现在此数组中.对的任何更改此属性未设置动画.用setItems:animated:方法动画更改.

@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.

默认值为nil

是否设置了项目数组,是否可以打印出 NSLog(@%@",myToolBar.items); 的值以查看其是否为nil并查看其中有多少UIBarButtonItem

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

这篇关于是否可以使用标签访问UIBarButtonItem?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆