• Explaining difference between automaticallyAdjustsScrollViewInsets, extendedLayoutIncludesOpaqueBars, edgesForExtendedLayout


    automaticallyAdjustsScrollViewInsets:在导航栏透明时用到

    In your viewDidLoad method, add if([self respondsToSelector:@selector(edgesForExtendedLayout)]) self.edgesForExtendedLayout = UIRectEdgeNone; which will force your view to start below the status bar

    Starting in iOS7, the view controllers use full-screen layout by default. At the same time, you have more control over how it lays out its views, and that's done with those properties:

    edgesForExtendedLayout

    Basically, with this property you set which sides of your view can be extended to cover the whole screen. Imagine that you push a UIViewController into a UINavigationController. When the view of that view controller is laid out, it will start where the navigation bar ends, but this property will set which sides of the view (top, left, bottom, right) can be extended to fill the whole screen.

    Let see it with an example:

    Here you are not setting the value of edgesForExtendedLayout, therefore the default value is taken (UIRectEdgeAll), so the view extends its layout to fill the whole screen.

    This is the result:

    without edges for extended layout, the view fills the whole screen

    As you can see, the red background extends behind the navigation bar and the status bar.

    Now, you are going to set that value to UIRectEdgeNone, so you are telling the view controller to not extend the view to cover the screen:

    And the result:

    with edgesForExtendedLayout set, the view is just under the navigation

    automaticallyAdjustsScrollViewInsets

    This property is used when your view is a UIScrollView or similar, like a UITableView. You want your table to start where the navigation bar ends, because you wont see the whole content if not, but at the same time you want your table to cover the whole screen when scrolling. In that case, setting edgesForExtendedLayout to None won't work because your table will start scrolling where the navigation bar ends and it wont go behind it.

    Here is where this property comes in handy, if you let the view controller automatically adjust the insets (setting this property to YES, also the default value) it will add insets to the top of the table, so the table will start where the navigation bar ends, but the scroll will cover the whole screen.

    This is when is set to NO:

    the table will scroll over the whole screen, but starts out partially covered

    And YES (by default):

    the table scrolls over the whole screen, and starts just under the navigation

    In both cases, the table scrolls behind the navigation bar, but in the second case (YES), it will start from below the navigation bar.

    extendedLayoutIncludesOpaqueBars

    This value is just an addition to the previous ones. By default, this parameter is set to NO. If the status bar is opaque, the views won't be extended to include the status bar, even if you extend your view to cover it (edgesForExtendedLayout to UIRectEdgeAll).

    If you set the value to YES, this will allow the view to go underneath the status bar again.

    If something is not clear, write a comment and I'll answer it.

    How does iOS know what UIScrollView to use?

    iOS grabs the first subview in your ViewController's view, the one at index 0, and if it's a subclass of UIScrollView then applies the explained properties to it. 

    Of course, this means that UITableViewController works by default (since the UITableViewis the first view).

    https://stackoverflow.com/questions/18798792/explaining-difference-between-automaticallyadjustsscrollviewinsets-extendedlayo

  • 相关阅读:
    转载: ubuntu13.04下载android4.0.1源码过程
    Android横竖屏切换总结
    java.lang.reflection打印一个类的全部信息
    js实现ctrl+v上传图片
    阿里云oss,简单上传
    FastDFS搭建
    nginx配置反向代理和负载均衡
    nginx配置虚拟机
    linux下安装nginx
    linux安装jdk
  • 原文地址:https://www.cnblogs.com/feng9exe/p/9628501.html
Copyright © 2020-2023  润新知