It has been four or five years since MJ was first heard and used by bloggers. After such a long time, MJ is still strong and powerful. Many custom updates are extended by MJ. A few years ago, when I first started using MJ, I had a crash caused by MJ refresh, but I didn’t care.
_circleTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight - kNavigationBarHeight) style:UITableViewStyleGrouped]; _circleTableView.delegate = self; _circleTableView.dataSource = self; _circleTableView.estimatedRowHeight = 120; _circleTableView.rowHeight = UITableViewAutomaticDimension; _circleTableView.separatorStyle = UITableViewCellSelectionStyleNone; [self.view addSubview:_circleTableView]; MJRefreshNormalHeader *header = [MJRefreshNormalHeader headerWithRefreshingTarget:self refreshingAction:@selector(loadNewData)]; / / set up automatic switching transparency (below the navigation bar automatically hide) header. AutomaticallyChangeAlpha = YES; / / hide time header. LastUpdatedTimeLabel. Hidden = YES; // Set header self.circleTableView.mj_header = header; self.circleTableView.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(loadMoreData)]; #pragma mark - loadNewData - (void)loadNewData { _page = 1; [_tucaoDataArray removeAllObjects]; [self requestData]; } #pragma mark - loadMoreData - (void)loadMoreData { _page++; [self requestData]; }Copy the code
The loadNewData method deletes the data source before the data is requested. If the TableView rolls during the request, the data source is empty and has no data, it will crash directly. If the TableView doesn’t scroll, there’s also a chance that it will crash, which is episodic. The best practice is to delete data after the request is received, save new data, and do not delete data in advance. It was a stupid mistake.