1

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

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

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

4

2 回答 2

2

1:如果您使用的是 UINavigationController 并且您的导航栏可见,则此方法有效

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

if(systemVersion >=7.0f)
{

self.edgesForExtendedLayout=UIRectEdgeNone;

 }

或者您也可以从 stoyboard 设置

在此处输入图像描述

2:另一种解决方案是。您可以使用 IOS 6/7 Delta

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 属性

在此处输入图像描述

于 2013-10-21T11:23:59.167 回答
0

There are several macros which are helpful in this case

#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)

To see is your iOS version is greater than iOS7:

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

However is this IF-ELSE is still long, you can do something like this

#define IS_IOS_7 SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0")

and then

if (IS_IOS_7) {
  // instruction...
}
于 2013-10-21T11:17:01.587 回答