reloadData的错误方法

在animate中reloadData是相当错误的,会引起变得缓慢!!

        [UIView animateWithDuration:0 animations:^{
            
            NSLog(@"lml-info-vc-test-net-animations-reloadData-bigin");
            
            [self.pre_tableView reloadData];
            NSLog(@"lml-info-vc-test-net-animations-reloadData-end");
        } completion:^(BOOL finished) {
            //Do something after that...
            [_pre_tableView.mj_footer endRefreshing];
            [_pre_tableView.mj_header endRefreshing];
            
        }];

官方文档明确说了不能在animate中reloadData:
https://developer.apple.com/reference/uikit/uitableview/1614862-reloaddata?language=objc

Discussion

Call this method to reload all the data that is used to construct the table, including cells, section headers and footers, index arrays, and so on. For efficiency, the table view redisplays only those rows that are visible. It adjusts offsets if the table shrinks as a result of the reload. The table view’s delegate or data source calls this method when it wants the table view to completely reload its data. It should not be called in the methods that insert or delete rows, especially within an animation block implemented with calls to beginUpdates and endUpdates.

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容