[iOS11] contentInsetAdjustmentBehavior 问题, push back时, 界面会上下移动.

https://stackoverflow.com/questions/45573829/weird-uitableview-behaviour-in-ios11-cells-scroll-up-with-navigation-push-anima

 

在你的tablview/controller基类设置

 if (@available(ios 11.0,*)) {
        self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
    }

 

不要用  `[UIScrollView appearance]` 的方法, 不生效.

 

 

 

 

PS: 搜索这个问题的话, 国内的多个文章都是抄的同一篇, 且是错的.

如下是错的.

  1. 目前发现所有的Scrollview 及其子类都需要设置 contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever ,  
  2. 工程中大量使用列表的同学不要慌,不要忙,因为UIView及其子类都遵循UIAppearance协议,我们可以进行全局配置:    
  3.     
  4. // AppDelegate 进行全局设置    
  5.     if (@available(iOS 11.0, *)){    
  6.         [[UIScrollView appearance] setContentInsetAdjustmentBehavior:UIScrollViewContentInsetAdjustmentNever];    
  7.     }    
  8.     
  9. 这样一来使用UITableview 、UICollectionView、UIScrollview的时候就不需要再单独设置该属性了。  
posted @ 2017-11-08 10:39  willbin  阅读(1123)  评论(0编辑  收藏  举报