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

 

转载于:https://www.cnblogs.com/gaozhang12345/p/8303389.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值