zoukankan      html  css  js  c++  java
  • IOS 11 下适配UITableView

    9月份苹果发布了IOS11Iphone X,这一操作系统一硬件对于开发者适配上面还是造作了不少蛋疼的地方。先来看看IOS 11,这些蛋疼的需要适配的地方:

    1UIScrollView及其子类在IOS 11之前的版本UI显示完全正常,但是在IOS 11上面会显示奇葩的界面。

    1)先看一下UITablevIew

    原本在VC里面的automaticallyAdjustsScrollViewInsets竟然过期了,在IOS 11 APPLE推荐使用UIScrollViewcontentInsetAdjustmentBehavior属性进行设置自动计算滚动视图的内容边距。

    @property(nonatomic,assign) BOOL automaticallyAdjustsScrollViewInsets

    IOS11SDK下,UIScrollView的这个属性

    @property(nonatomic) UIScrollViewContentInsetAdjustmentBehavior contentInsetAdjustmentBehavior //这个属性是一个枚举类型的

    {

    UIScrollViewContentInsetAdjustmentAutomatic,//scrollView会自动计算和适应顶部和底部的内边距并且在scrollView 不可滚动,也会设置内边距.

    UIScrollViewContentInsetAdjustmentScrollableAxes,  //自动适应边距

    UIScrollViewContentInsetAdjustmentNever // automaticallyAdjustsScrollViewInsets=NO有着同样的效果,不计算内边距

    UIScrollViewContentInsetAdjustmentAlways//根据safeAreaInsets (安全区域)计算内边距

    }

    所以,在IOS 11 下,需要设置ScrollView

    self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;

    如果需要全局设置的话,需要这么设置:

    if (@available(iOS 11.0, *)) {

     

    [[UIScrollView appearance] setContentInsetAdjustmentBehavior:UIScrollViewContentInsetAdjustmentNever];

    }

    这样设置后使用UITableview 、UICollectionView、UIScrollview的时候就不需要再单独设置该属性了,因为UIView以及他的子类都是遵循UIAppearance协议的。

  • 相关阅读:
    Twitter注册
    iOS项目的完整重命名方法图文教程
    加载gif动态图的三种方式
    只 一行显示可左右滚动的文本(UITextField中文限制)
    iOS学习资料链接
    GCD常用方法
    移动端轮播完整版css3加原生写法
    zepto-touch.js插件
    移动端续讲及zepto移动端插件外加touch插件介绍
    解决ios和Android的差异
  • 原文地址:https://www.cnblogs.com/spider-pei/p/7592906.html
Copyright © 2011-2022 走看看