1.有时你命名设置了某控件的y坐标为0,确总是被导航栏遮挡住,如下:

UILabel *label = [[UILabel alloc] init];
    label.text = @"请看Y坐标";
    label.frame = CGRectMake(10, 0, 300, 88);
    label.backgroundColor = [UIColor redColor];
    [self.view addSubview:label];

代码效果如下:

原因分析:

在IOS7以后 ViewController 开始使用全屏布局的,而且是默认的行为通常涉及到布局, 就离不开这个属性 edgesForExtendedLayout,它是一个类型为UIExtendedEdge的属性,指定边缘要延伸的方向,它的默认值很自然地是UIRectEdgeAll,四周边缘均延伸,就是说,如果即使视图中上有navigationBar,下有tabBar,那么视图仍会延伸覆盖到四周的区域。

解决方法:
①:self.edgesForExtendedLayout = UIRectEdgeNone;
②:self.navigationController.navigationBar.translucent = NO; (在iOS 6之前(包括iOS 6)translucent默认为NO,从iOS 7开始就默认为YES。)
 
2. 使用UIScrollView也会遇到此种问题:
    UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 64, SCREENW, 100)];
    scrollView.contentSize = CGSizeMake(SCREENW * 2, 100);
    scrollView.backgroundColor = [UIColor redColor];
    [self.view addSubview:scrollView];
    
    UILabel *label = [[UILabel alloc] init];
    label.text = @"请看Y坐标";
    label.frame = CGRectMake(10, 0, 300, 88);
    label.backgroundColor = [UIColor redColor];
    [scrollView addSubview:label];
 
代码效果如下:
 
 
这种情况也是edgesForExtendedLayout属性造成的。
同样,也需要设置self.edgesForExtendedLayout = UIRectEdgeNone;即可解决问题。
 
 

UIViewController 的 edgesForExtendedLayout、automaticallyAdjustsScrollViewInsets属性的更多相关文章

  1. edgesForExtendedLayout,automaticallyAdjustsScrollViewInsets, extendedLayoutIncludesOpaqueBars的影响

    在IOS7以后 ViewController 开始使用全屏布局的,而且是默认的行为通常涉及到布局 就离不开这个属性 edgesForExtendedLayout,它是一个类型为UIExtendedEd ...

  2. UIViewController的edgesForExtendedLayout属性

    UIViewController的edgesForExtendedLayout属性 想必大家都遇到一种情况,明明y坐标设置的是0,但是总是被讨厌的导航栏给遮住.比如下面这个情况: UILabel *l ...

  3. iOS开发-automaticallyAdjustsScrollViewInsets属性

    iOS开发-automaticallyAdjustsScrollViewInsets属性 Available in iOS 7.0 and later. 简单点说就是automaticallyAdju ...

  4. 关于tableView的那些坑(一)—— automaticallyAdjustsScrollViewInsets属性

    最近用tabbar来切换控制器,用childViewController来实现多控制器管理,多列表切换,在子控制器中设置了automaticallyAdjustsScrollViewInsets属性为 ...

  5. iOS对UIViewController生命周期和属性方法的解析

    目录[-] iOS对UIViewController生命周期和属性方法的解析 一.引言 二.UIViewController的生命周期 三.从storyBoard加载UIViewController实 ...

  6. 【iOS开发】iOS对UIViewController生命周期和属性方法的解析

    iOS对UIViewController生命周期和属性方法的解析 一.引言 作为MVC设计模式中的C,Controller一直扮演着项目开发中最重要的角色,它是视图和数据的桥梁,通过它的管理,将数据有 ...

  7. iOS edgesForExtendedLayout、extendedLayoutIncludesOpaqueBars、automaticallyAdjustsScrollViewInsets属性详解

    edgesForExtendedLayout: 在IOS7以后 ViewController 开始使用全屏布局的,而且是默认的行为通常涉及到布局,就离不开这个属性 edgesForExtendedLa ...

  8. edgesForExtendedLayout、extendedLayoutIncludesOpaqueBars、automaticallyAdjustsScrollViewInsets属性详解 )——转载

    edgesForExtendedLayout: 在ios7适配中,布局问题是一个很头痛也很重要的问题,因为在ios7中viewController使用了全屏布局的方式,也就是说导航栏和状态栏都是不占实 ...

  9. iOS UITableviewWrapperView 和 automaticallyAdjustsScrollViewInsets属性

    关于在navigationController下面使用tableView在竖直方向会遇到frame的y值的困惑, 会遇到视图控制器的这个属性:automaticallyAdjustsScrollVie ...

随机推荐

  1. 洛谷 P2048 [NOI2010]超级钢琴(优先队列,RMQ)

    传送门 我们定义$(p,l,r)=max\{sum[t]-sum[p-1],p+l-1\leq t\leq p+r-1 \}$ 那么因为对每一个$p$来说$sum[p-1]$是一个定值,所以我们只要在 ...

  2. IDEA导入HttpServlet包

    转载此篇博客,言简意赅.https://blog.csdn.net/liu_yanzhao/article/details/78838670

  3. 关于Mac系统中my sql 和navicat for mysql 的连接问题。

    我这个完完全全的技术小小白,经过数个小时的网搜,navicat for mysql和mysql终于可以可以正常连接了,好开森啊!,我把我遇到的问题,以及解决方法记录下来,希望也可以对遇到同样问题的能够 ...

  4. 字符串split函数

    https://www.cnblogs.com/hjhsysu/p/5700347.html 函数:split() Python中有split()和os.path.split()两个函数,具体作用如下 ...

  5. ZipUtils

    package com.yundaex.common.exception.util; import java.io.ByteArrayInputStream; import java.io.ByteA ...

  6. byte取高4位,低4位,byte转int

    byte abyte =-1; System.out.println(abyte); System.out.println(Integer.toBinaryString(abyte)); //取高四位 ...

  7. Win10专业版系统下添加其他国家语言

    Win10专业版系统下如何添加其他国家语言?国内的win10专业版系统默认情况下是安装简体中文,但是有的用户出于工作原因需要使用其它字体.比如外国友人就需要使用英语,西班牙等.其实win10专业版是支 ...

  8. NET Core+MySql+Nginx

    NET Core+MySql+Nginx 容器化部署 .NET Core容器化@Docker.NET Core容器化之多容器应用部署@Docker-Compose.NET Core+MySql+Ngi ...

  9. 安装Jaspersoft Studio

    下载位置:http://community.jaspersoft.com/project/jaspersoft-studio/releases.

  10. js和jq中常见的各种位置距离之offsetLeft/clientLeft/scrollLeft (一)

    offsetLeft offsetTop offsetWidth offsetHeight offsetLeft:元素的边框的外边缘距离与已定位的父容器(offsetparent)的左边距离(不包括元 ...