iOS11 tableView下拉刷新问题

if(@available(iOS 11.0,*)){
        self.deviceListTableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
        self.deviceListTableView.contentInset=UIEdgeInsetsMake(64,0,49,0);
        self.deviceListTableView.scrollIndicatorInsets = self.deviceListTableView.contentInset;
    }

放在

- (void)viewDidLoad {

 

  [super viewDidLoad];

。。。。放这里!!!

}




问题

还有就是说如果你使用了MJRefresh进行刷新,并且你隐藏了导航栏,就会出现下拉刷新错乱的问题。
这跟我这哥们问的问题是一种类型的,因为iOS 11上废除了automaticallyAdjustsScrollViewInsets这个方法,使用UIScrollView's contentInsetAdjustmentBehavior来代替,解决办法就是一段代码:
OC:

 if (@available(iOS 11.0, *)) {
        self.collectionView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
    }else {
        self.automaticallyAdjustsScrollViewInsets = NO;
    }
swift:

if #available(iOS 11.0, *) {  
    tableView.contentInsetAdjustmentBehavior = .never  
} else {  
    self.automaticallyAdjustsScrollViewInsets = false  
}  
因为哥们是OC写的项目,大家用的时候注意写成Swift。

.iOS 11 下tableView的头视图和脚视图

在iOS11里面有时候在tableView的头部和尾部留白,因为苹果给滚动试图加进去了self-sizeing,开始计算逐步计算contentSize,默认如果不去实现viewForHeaderInSection就不会调用heightForHeaderInSection,尾部试图一样。

func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {  
    return nil  
}  
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {  
    return nil  
}  
如果你不想实现viewForHeaderInSection也不想留白,那么只需要你把self-sizeing自动估高关闭即可

/// 自动关闭估算高度,不想估算那个,就设置那个即可
self.tableView.estimatedRowHeight = 0
self.tableView.estimatedSectionHeaderHeight = 0
self.tableView.estimatedSectionFooterHeight = 0

 

posted on 2018-01-17 15:59  高彰  阅读(729)  评论(0编辑  收藏  举报

导航