以前看到过在iOS9.0
上可能会出现刷新调用数据源方法失效通过使用局部刷新便可解决,这次使用过程中cell
中带有图片,需要根据选中的状态来调整不同的图片展示。
结果发现问题,第一次启动时总会慢上一拍,直至操作几下之后才恢复正常。
在层层调试后发现所有该调用的方法都得到调用,那唯一的情况就是tableView
自己的刷新机制有问题,再后来使用tableView
的局部刷新便可以解决了问题。
全局刷新:
[tableView reloadData];
局部刷新:
NSIndexPath *indexPath1 = [NSIndexPath indexPathForRow:1 inSection:0]; // tableView的分类,便于使用,想使用collection直接写便可
NSIndexPath *indexPath2 = [NSIndexPath indexPathForRow:2 inSection:0];
NSArray *tmpArr = @[indexPath1,indexPath2];
[tableView reloadRowsAtIndexPaths:tmpArr withRowAnimation:UITableViewRowAnimationAutomatic];