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];








网友评论