【问题标题】:Add top layout guide in NIB file (XIB) [duplicate]在 NIB 文件 (XIB) 中添加顶部布局指南 [重复]
【发布时间】:2013-12-11 03:10:55
【问题描述】:

如何在 NIB 文件中添加顶部布局指南,或者如何从顶部导航栏和状态栏指定空间,以免在 ios 6 和 iOS 7 之间产生问题?

【问题讨论】:

标签: ios iphone ios7 autolayout


【解决方案1】:

您可以通过在 iOS7 SDK 中实现名为 edgesForExtendedLayout 的新属性来做到这一点

-(void)viewDidLoad {
      if ([self respondsToSelector:@selector(edgesForExtendedLayout)])
         self.edgesForExtendedLayout = UIRectEdgeNone;
}

如果你使用的是导航栏和 xcode5 那么..

在 Interface Builder 中,选择视图控制器,然后导航到属性检查器。在“延伸边缘”中。检查顶部栏下

我已经从Here解决了我的问题

【讨论】:

  • 从技术上讲,您正在访问setEdgesForExtendedLayout:,因此您有点检查来自错误方法的响应。但这只是吹毛求疵。
  • 这无济于事,因为我有一个希望通过透明导航栏可见的背景。 edgesForExtendedLayout 将一切推倒。
【解决方案2】:

我正在以编程方式进行操作。
因为您必须检查 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
            {


            }

希望这会有所帮助....

【讨论】:

  • 这段代码的问题在于它高度依赖于屏幕大小。这类事情往往会经常变化!
【解决方案3】:

我认为您需要为此编写此条件

 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.
   } 

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-10-05
    • 1970-01-01
    • 1970-01-01
    • 2014-11-15
    • 2014-06-23
    • 2018-02-28
    • 2014-06-24
    • 1970-01-01
    相关资源
    最近更新 更多