iOS11TableView刷新reloadSections发生错乱

就像QQ分组那样会刷新可以实现分组的展开和闭合
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return self.dataMrray.count;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    GlobalModel * model = self.dataMrray[section];
    if (model.isOpen) {
        return model.dataArray.count;
    }else{
        return 0;
    }
}

然后在HedaerView回调写入

[self.tableView reloadSections:indexSet withRowAnimation:UITableViewRowAnimationAutomatic];

经过测试iOS11直接刷新会发生错乱,屏幕大的手机发现不了 屏幕小的手机会出现如下图:


8E47F8D1-1AD9-49A4-8254-A1E88D68B0EB.png

加入以下代码就可以了

self.tableView.estimatedRowHeight = 0;
self.tableView.estimatedSectionHeaderHeight = 0;
self.tableView.estimatedSectionFooterHeight = 0;
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容