三个方法,
1,
```objectivec
dispatch_async(dispatch_get_main_queue(), ^ { //加入到主线程,强制执行reload
[self.collectionView reloadData];
});
2,
```objectivec
[self.collectionView reloadSections:[NSIndexSet indexSetWithIndex:0]];//指定刷新的section或者cell
3,reloadSections或者reloadData闪动,因为layer有个隐式动画,在下面的方法里面刷新就行了。
[UIView performWithoutAnimation:^{
[self.collectionView reloadSections:[NSIndexSet indexSetWithIndex:0]];
}];
综上,最保险的方法
dispatch_async(dispatch_get_main_queue(), ^ { //加入到主线程,强制执行reload
[UIView performWithoutAnimation:^{
[self.collectionView reloadSections:[NSIndexSet indexSetWithIndex:0]];
}];
});
顺带提一下tabview有时候不走cellforrow
在tabview的frame宽度或者高度为0的时候,这个时候就不会走cellforrow,或许是因为不想浪费性能所以这样设计,特别是在用monsary布局的时候,很容易出现这种情况