【发布时间】:2013-03-16 09:27:23
【问题描述】:
我开发了一个具有部署目标和ios sdk as 6.0的应用程序。后来我的客户要求应用程序应该在 ios 5.0+ 设备中运行。所以我已将部署目标更改为 5.0 并禁用了 IB 的自动布局属性,如堆栈中提到的here,但现在我收到如下所示的错误:
> -[UIBarButtonItem setBackgroundImage:forState:style:barMetrics:]:无法识别的选择器发送到实例 0x2971f0
我没有发现我的 UIBarButtonItem 有什么问题,
addButton = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemAdd
target:self
action:@selector(addProject)];
现在我正在努力寻找解决方案,等待您的宝贵帮助.. 提前致谢。
【问题讨论】:
-
该方法仅适用于iOS 6.0+
-
我没有使用过类似的方法。这就是我的代码中的内容:- addButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(addProject)] ;
-
它适用于 iOS 5.0 及更高版本。
-
@ElliottPerry 你应该把它写成答案,因为它是正确的。他需要做responstoselector并拥有两个版本的add按钮。
-
@mvp 你说得对,那行代码应该没有问题。问题一定出在其他地方。你能不能逗我一下,在你的代码库中搜索
setBackgroundImage:forState:style:barMetrics:方法(显然不要搜索整行文本,因为它会被参数名称和类型分解。尝试搜索“barMetrics”)。
标签: iphone ios5 ios6 uibarbuttonitem