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   高彰  阅读(734)  评论(0编辑  收藏  举报

编辑推荐:
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
阅读排行:
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
历史上的今天:
2017-01-17 has no restore identifier but the delegate implements the centralManager:willRestoreState: method. Restoring will not be supported
2017-01-17 五.oc文件操作
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

导航

统计

点击右上角即可分享
微信分享提示