UITableView
2019-03-18 本文已影响0人
kangomake
1.[self.tableView reloadData]
tableView调用
reloadData
之后,立即调用numberOfRowsInSection
,但是cellForRowAt
和heightForRow
是异步调用
想要调用reloadData
之后立即调用所有代理方法,我们可以添加layoutIfNeeded
让TableView强制布局
self.tableView.reloadData()
self.tableView.layoutIfNeeded()
2.tableView刷新部分cell
//刷新一行
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:index inSection:0];
[self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:indexPath,nil] withRowAnimation:UITableViewRowAnimationFade];
//刷新一组
NSIndexSet* indexSet = [[NSIndexSetalloc]initWithIndex:1];
[self.myTableViewreloadSections:indexSetwithRowAnimation:UITableViewRowAnimationAutomatic];