【发布时间】:2013-10-01 07:37:32
【问题描述】:
我正在努力编译一个用于 iOS 6 和 iOS 7 的 iPad 应用程序。
这是我不断收到的信息:
Property 'barTintColor' not found on object of type 'UITabBar *'; did you mean 'tintColor'?
目标的Base SDK 设置为Latest iOS (iOS 7.0),iOS Deployment Target 设置为iOS 6.0。我对该项目进行了清理。
代码如下:
在.h文件中:
@property (nonatomic, strong) IBOutlet UITabBar *tabbedBar;
.m 文件中:
if ([tabbedBar respondsToSelector: @selector(barTintColor)]) {
tabbedBar.barTintColor = [UIColor blackColor];
}
我正在针对 iOS 7 SDK 进行编译,因此它应该了解 barTintColor。知道可能是什么问题吗?
更新:
好的,我正在取得进展,但不太明白为什么。
查看此 Xcode 屏幕截图。请注意我的 iPad 3 在 Active Scheme 选择中的两个条目。有什么区别?如果我选择顶部选项,我会收到错误消息。如果我选择底部选项,它会起作用。
谁能解释为什么同一个设备在这个列表中出现两次,为什么当我选择一个而不是另一个时它会起作用?仅供参考,该设备已安装 iOS 6。
【问题讨论】:
-
这是运行时错误还是编译错误?你可以试试
@selector(setBarTintColor:)吗? -
你试过选择器 setBarTintColor: 吗?如 [tabbedBar setBarTintColor:[UIColor blackColor]];
-
抱歉,Xcode 也不知道
setBarTintColor。看到这个截图link -
你做错了。也许清理项目或退出 Xcode 并再次运行?我设置了
Latest iOS 7 SDK和Target to 6.0,它对我有用。如前所述,在@selector()中,您必须输入setBarTintColor:。 -
嗯。我看到我插入的 iOS 设备在 Xcode 5 中也列出了两次。我只是把它归结为 Xcode,因此我期待这种事情。