美文网首页
iOS11TableView刷新reloadSections发生

iOS11TableView刷新reloadSections发生

作者: 未央生 | 来源:发表于2018-02-05 11:06 被阅读1107次
就像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;

相关文章

网友评论

      本文标题:iOS11TableView刷新reloadSections发生

      本文链接:https://www.haomeiwen.com/subject/svebzxtx.html