【发布时间】:2013-12-11 03:10:55
【问题描述】:
如何在 NIB 文件中添加顶部布局指南,或者如何从顶部导航栏和状态栏指定空间,以免在 ios 6 和 iOS 7 之间产生问题?
【问题讨论】:
标签: ios iphone ios7 autolayout
如何在 NIB 文件中添加顶部布局指南,或者如何从顶部导航栏和状态栏指定空间,以免在 ios 6 和 iOS 7 之间产生问题?
【问题讨论】:
标签: ios iphone ios7 autolayout
您可以通过在 iOS7 SDK 中实现名为 edgesForExtendedLayout 的新属性来做到这一点
-(void)viewDidLoad {
if ([self respondsToSelector:@selector(edgesForExtendedLayout)])
self.edgesForExtendedLayout = UIRectEdgeNone;
}
或
如果你使用的是导航栏和 xcode5 那么..
在 Interface Builder 中,选择视图控制器,然后导航到属性检查器。在“延伸边缘”中。检查顶部栏下
我已经从Here解决了我的问题
【讨论】:
setEdgesForExtendedLayout:,因此您有点检查来自错误方法的响应。但这只是吹毛求疵。
edgesForExtendedLayout 将一切推倒。
我正在以编程方式进行操作。
因为您必须检查 ios 7 和其他版本的帧大小。
因为对于状态栏,您必须在 IOS 7 等中管理 20 像素。
因此,只需在任何 IOS 中根据需要将 View 放入 XIB 中,对于其他您可以通过此管理的...
CGSize result = [[UIScreen mainScreen] bounds].size;
if(result.height == 480)
{
NSArray *vComp = [[UIDevice currentDevice].systemVersion componentsSeparatedByString:@"."];
if ([[vComp objectAtIndex:0] intValue] >= 7) {
NSLog(@"Ios7 resize the frame");
}
else
{
}
}
if(result.height == 568)
{
NSArray *vComp = [[UIDevice currentDevice].systemVersion componentsSeparatedByString:@"."];
if ([[vComp objectAtIndex:0] intValue] >= 7) {
NSLog(@"Ios7 resize the frame");
}
else
{
}
希望这会有所帮助....
【讨论】:
我认为您需要为此编写此条件
float SystemVersion=[[[UIDevice currentDevice] systemVersion] floatValue];
if(SystemVersion<7.0f)
{
//Currently your app is running in IOS6 or older version. So you need not
to do anything.
}
else
{
// Currently your app is running in IOS7.
}
【讨论】: