【发布时间】:2014-01-13 12:16:43
【问题描述】:
我在导航栏中有一个 UIBarButton(VC 嵌入在导航控制器中)。 在 IB 中,我使用标识符设置按钮:
如何从代码中设置此属性?
【问题讨论】:
标签: ios properties uibarbuttonitem identifier
我在导航栏中有一个 UIBarButton(VC 嵌入在导航控制器中)。 在 IB 中,我使用标识符设置按钮:
如何从代码中设置此属性?
【问题讨论】:
标签: ios properties uibarbuttonitem identifier
你应该可以这样设置
UIBarButtonItem *trashButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemTrash target:self action:nil];
查看此here 的 Apple 文档
不幸的是,Apple 只允许您在初始化 UIBarButtonItem 时设置它,没有属性可以设置它。
【讨论】:
alloc init时你必须这样做。烦人,但这正是 Apple 喜欢的方式——烦人。