【问题标题】:How do I conditionally load assets for iOS7 and iOS6?如何有条件地加载 iOS 7 和 iOS 6 的资产?
【发布时间】:2013-09-24 20:07:23
【问题描述】:

所以我正在阅读过渡指南,如果我使用情节提要,我可以有条件地为 iOS6 或 iOS7 加载资产。我正在使用它,但我不明白如何将资产加载到故事板中。

https://developer.apple.com/library/ios/documentation/userexperience/conceptual/TransitionGuide/SupportingEarlieriOS.html

【问题讨论】:

    标签: iphone ios6 storyboard ios7 xcode5


    【解决方案1】:

    你可以使用这些:

    /** iOS Version Comparisons */
    #define SYSTEM_VERSION_EQUAL_TO(v)                  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)
    #define SYSTEM_VERSION_GREATER_THAN(v)              ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)
    #define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v)  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
    #define SYSTEM_VERSION_LESS_THAN(v)                 ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
    #define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v)     ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)
    
    
    if ( SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0") ) 
        // do something for iOS 7
    else
        // do something for iOS 6, 5, 4
    

    你也可以这样使用:

    [myButton setBackgroundImage:( SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0") ? @"image_ios7" : @"image_ios6" )];
    

    【讨论】:

    • 我明白了,我的问题是我有两个资产,一个用于 iOS7,一个用于 iOS6,两者都尊重同名资产。如果它在 iOS7 上,我希望能够告诉情节提要使用一种资产,如果它是 iOS6 及更低版本,则使用另一种资产。
    • 好吧,我试图避免通过代码加载东西。我几乎通过故事板进行了所有设置。
    • 最好的方法是编程。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多