【问题标题】:Xcode 5, How to build an app with UI compatible with IOS 6 as well as IOS 7 [duplicate]Xcode 5,如何使用与 IOS 6 和 IOS 7 兼容的 UI 构建应用程序 [重复]
【发布时间】:2013-10-21 11:04:06
【问题描述】:

我正在使用 Xcode 5。 我想构建一个与 IOS 6 以及 IOS 7 兼容的 UI 的应用程序。任何人都可以帮我解决这个问题。应用应兼容 iPhone (3gs)、iPhone Retina 3.5 和 iPhone Retina 4。

当我在装有 IOS 6 的 iPhone (3GS) 上观看时,UI 会失真。

我已尝试启用自动布局,但某些屏幕的问题仍然存在。

【问题讨论】:

标签: iphone ios objective-c ios7 xcode5


【解决方案1】:

1:如果您使用的是 UINavigationController 并且您的导航栏是可见的,那么这是可行的

float systemVersion=[[[UIDevice currentDevice]systemVersion]floatValue];

if(systemVersion >=7.0f)
{

self.edgesForExtendedLayout=UIRectEdgeNone;

 }

或 您也可以从 stoyboard 设置

2:另一种解决方案是 .你可以使用 IOS 6/7 Deltas

i) take new view and setting its Y postion is 20

ii) move all control into this view

iii)setting new view Detas Y Property is -20

现在你查看hirerachy 是这样的

您可以在下图中看到如何设置 Deltas 属性

【讨论】:

    【解决方案2】:

    有几个宏在这种情况下很有帮助

    #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)
    
    #define APP_VERSION_GREATER_THAN_OR_EQUAL_TO(v)     ([[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"] compare:v options:NSNumericSearch] != NSOrderedAscending)
    

    看看你的iOS版本是否大于iOS7:

    if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0")) {
     // iOS 7 specific instruction
    }
    

    但是这个 IF-ELSE 还是很长,你可以这样做

    #define IS_IOS_7 SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0")
    

    然后

    if (IS_IOS_7) {
      // instruction...
    }
    

    【讨论】:

      猜你喜欢
      • 2023-03-06
      • 1970-01-01
      • 2012-12-23
      • 1970-01-01
      • 2013-10-29
      • 1970-01-01
      • 2013-11-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多