I'm struggling to compile an iPad app for use on iOS 6 and iOS 7.
Here's the message I keep getting:
Property 'barTintColor' not found on object of type 'UITabBar *'; did you mean 'tintColor'?
The Base SDK
for the target is set to Latest iOS (iOS 7.0)
, and the iOS Deployment Target
is iOS 6.0
. I did a Clean on the project.
Here is the code:
In the .h file:
@property (nonatomic, strong) IBOutlet UITabBar *tabbedBar;
In the .m file:
if ([tabbedBar respondsToSelector: @selector(barTintColor)]) {
tabbedBar.barTintColor = [UIColor blackColor];
}
I'm compiling against the iOS 7 SDK, so it should know about barTintColor. Any idea what the problem could be?
Updated:
Okay, I'm making progress, but not quite understanding why.
See this Xcode screenshot. Note the two entries for my iPad 3 in the Active Scheme selection. What is the difference? If I choose the top option, I get the error. If I choose the bottom option, it works.
Can anyone explain why the same device appears twice in this list, and why it works when I choose one and not the other? FYI, the device has iOS 6 installed.
You have two SDKs installed in your Xcode: for iOS 6 and iOS 7. Now, when that happens, if you plug in your iOS 7 device, it shows as two devices (i.e. options) in the device selector: first row is for iPad 3 (iOS 6), second for iPad 3 (iOS 7).
The problem with your error is that when you select iPad 3 (iOS 6), Xcode still reads the device as iOS 7 (and that's what it has installed, anyway) so when building it passes the [tabbedBar respondsToSelector: @selector(barTintColor)]
code (it responds to the selector, 'cause hey, it's iOS 7), but because you're building for iOS 6, at the same time it raises an error, 'cause hey, iOS 6 doesn't have that method! Fun.
Basically, you can't use the iOS 6 option when testing on the iOS 7 device. You either need a iOS 6 device, or you're stuck with the simulator for testing old versions.
EDIT: You can test what I'm saying in the following manner — instead of using respondsToSelector:
use
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0f) {
// code
}
and then select the first device in the list (iPad 3 iOS 6). You'll see that you go through the if
clause, but Xcode gives you an error that the selector isn't available on iOS 6.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With