Compiling an app that works in iOS 6 and iOS 7

后端 未结 1 552
孤街浪徒
孤街浪徒 2021-02-20 08:31

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 t         


        
1条回答
  •  遥遥无期
    2021-02-20 09:12

    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.

    0 讨论(0)
提交回复
热议问题