zoukankan      html  css  js  c++  java
  • automaticallyAdjustsScrollViewInsets 使用

    automaticallyAdjustsScrollViewInsets(个人认为iOS7中略坑爹的属性)  

     

    @当我们在一个UIViewController中同时创建2个tableView的时候,如果把它们的frame中的Y坐标设置为一样,你可能会发现它们的位置并没有达到你想要的结果.比如第一tableView个frame(0,0,320,568),另一个也frame(0,0,320,568),结果会发现第二个tableView的第一行数据被导航栏遮挡了,以至于我们不得已把第二个frame改成(0,64,320,568-64),虽然效果变成了我们想要的,但是却不知道这是什么原因.......

     

    另一说:

    self.automaticallyAdjustsScrollViewInsets = NO;
    看这个UIViewController的这个属性你就明白了,此属性默认为YES,这样UIViewController下如果只有一个UIScollView或者其子类,那么会自动留出空白,让scollview滚动经过各种bar下面时能隐约看到内容。但是每个UIViewController只能有唯一一个UIScollView或者其子类,如果超过一个,需要将此属性设置为NO,自己去控制留白以及坐标问题。

     

     

    其实这一切都是automaticallyAdjustsScrollViewInsets在作怪,我们可以先看一下官方文档中对它的描述:

    automaticallyAdjustsScrollViewInsets

    Specifies whether or not the view controller should automatically adjust its scroll view insets.

    @property(nonatomic, assign) BOOL automaticallyAdjustsScrollViewInsets

    Discussion

    Default value is YES, which allows the view controller to adjust its scroll view insets in response to the screen areas consumed by the status bar, navigation bar, and toolbar or tab bar. Set toNO if you want to manage scroll view inset adjustments yourself, such as when there is more than one scroll view in the view hierarchy.

    Availability

    • Available in iOS 7.0 and later.

    Declared In

    UIViewController.h

     

    哈哈,由此可见,当我们一个界面有多个tableView之类的,要将它设置为NO,完全由自己手动来布局,就不会错乱了.

  • 相关阅读:
    RMQ Tarjan的Sparse-Table算法
    POJ3461一道kmp题,字符串Hash也可
    hdu3294 Manacher算法模板
    SQL复制数据表及表结构
    Delphi ResourceString的用法
    锐浪报表 Grid++Report 一维码无法固定条形码打印宽度
    Delphi中点击网页弹出的Alert对话框的确定按钮
    Delphi实现获取句柄并发送消息的方法(FindWindow、FindWindowEx、EnumChildWindows、SendMessage)
    Delphi 常用API 函数列表
    Delphi WinAPI 消息函数 SendMessage函数和 PostMessage的区别
  • 原文地址:https://www.cnblogs.com/developer-ios/p/4912811.html
Copyright © 2011-2022 走看看