그냥 정상적인 작업을 수행하십시오. 서버에서 데이터를 요청하고 reloadSections
, tableview 새로 고치지,하지만 많은 충돌 로그를 가져옵니다. reloadData
으로 전화하면 모든 것이 정상입니다. reloadData
이 잘 작동한다고해도, reloadSections
이 더 효율적으로 작동하는 것으로 보입니다.
아무도 아이디어가 있습니까?UITableView 호출 reloadSections 메서드를 충돌합니다
[_pomelo onRoute:@"onTlive" withCallback:^(NSDictionary *data) {
@strongify(self);
if (self.liveTableView) {
[self.liveTableView configData:data refresh:self.playerView.isScreenPortrait];
}
}];
그런 다음 데이터를 config (설정)하고있는 tableview 새로 고침 : 지속적인 연결하여 서버에서
데이터 가져 오기
무효 갱신 : 여기
- (void)configData:(NSDictionary *)data refresh:(BOOL)refresh { if (!data || data.allKeys.count == 0) { return; } NSArray *liveArray = [data valueForKeyPath:@"body.data"]; [liveArray enumerateObjectsUsingBlock:^(NSString *obj, NSUInteger idx, BOOL * _Nonnull stop) { NSArray *liveDetailInfo = [obj componentsSeparatedByString:@"|"]; if (liveDetailInfo && liveDetailInfo.count > 0) { NSArray *tliveInfo = [liveDetailInfo.lastObject componentsSeparatedByString:@"^"]; SPBasketballLive *liveObject = [SPBasketballLive new]; liveObject.type = tliveInfo[0]; liveObject.time = tliveInfo[1]; liveObject.team = tliveInfo[2]; liveObject.playerId = tliveInfo[3]; liveObject.score = tliveInfo[4]; liveObject.text = tliveInfo[5]; liveObject.quarter = ((NSString *)liveDetailInfo.firstObject).integerValue; if (self.curMatch.liveInfo.count == liveObject.quarter) { NSMutableArray *quarterArray = self.curMatch.liveInfo.firstObject; [quarterArray insertObject:liveObject atIndex:0]; } else { NSMutableArray *quarterArray = [NSMutableArray new]; [quarterArray addObject:liveObject]; [self.curMatch.liveInfo insertObject:quarterArray atIndex:0]; } } }]; if (refresh) { if (_curMatch.liveInfo.count > 0) { [self.myTableView reloadSections:[NSIndexSet indexSetWithIndex:4] withRowAnimation:UITableViewRowAnimationNone]; } } }
는 충돌 로그입니다 : 섹션 4의 행 개수가 잘못되었습니다. 업데이트 후 기존 섹션에 포함 된 행 수 (98)는 t와 같아야합니다 업데이트 (96) 이전에 해당 섹션에 포함 된 행 수, 해당 섹션에서 삽입 또는 삭제 된 행 수 (삽입 된 0, 삭제 된 수)를 더한 값 또는 빼기 값 및 해당 섹션으로 들어오고 나가는 행 수를 더한 값 또는 빼기 값 이 경우 충돌이 발생하므로
reloadSection
방법은 부와 행 카운터를 업데이트하지 않기 때문에 당신이 섹션 또는 행 카운터를 변경하고UITableView
다른 카운터가있을 때
여기에 uitable을 다시로드하는 데 사용되는 코드를 추가하십시오. – KAR
어떤 충돌 로그가 표시되는지 여기에 표시하고 요구 사항을 명확히하십시오. – vaibhav