0.5秒ごとにリフレッシュされるテーブルビューがあります。頻繁に更新されるTableViewの流暢性を確保するにはどうすればよいですか?
私はそれのために何ができるのFPS減少
原因tableView reloadData
またはreloadSections: withRowAnimation:
それらの両方をuesd?
のtableViewは、新しいデータごとに0.5秒
と新しいデータを表示する必要があり、すぐにコード:
- (void)registerTableViewCells {
[self.tableView registerClass:[UITableViewCell1 class] forCellReuseIdentifier: UITableViewCell1Identifier];
[self.tableView registerClass:[UITableViewCell2 class] forCellReuseIdentifier: UITableViewCell2Identifier];
[self.tableView registerClass:[UITableViewCell3 class] forCellReuseIdentifier: UITableViewCell3Identifier];
}
- (void)makeUpDisplaySource {
NSMutableArray *arrM = [NSMutableArray array];
[arrM addObject:@[UITableViewCell1Identifier, @(60), @(1)]];
[arrM addObject:@[UITableViewCell2Identifier, @(55), @(10)]];
[arrM addObject:@[UITableViewCell3Identifier, @(30), @(10+_fortySeat*30)]];
// _fortySeat is boolValue
self.displaySource = arrM;
}
のtableViewデリゲート
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSArray *dataArr = self.displaySource[indexPath.section];
NSString *identifier = dataArr[0];
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier forIndexPath:indexPath];
return cell;
}
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
if ([NSStringFromClass(cell.class) isEqualToString:@"UITableViewCell1"]) {
UITableViewCell1 *newcell = (UITableViewCell1 *)cell;
[newcell updatCellUI];
}
else if ([NSStringFromClass(cell.class) isEqualToString:@"UITableViewCell2"]) {
UITableViewCell2 *newcell = (UITableViewCell2 *)cell;
[newcell updatCellUIBuy: model1 sell: model2];
}
else if ([NSStringFromClass(cell.class) isEqualToString:@"UITableViewCell3"]){
cell.backgroundColor = GL_CELL_BACKGROUD_COLOR;
[cell addSubview:self.someView];// someView is a lazy property
}
}
リロード全テーブルデータの再ロードセクションのみを使用できます –
1)コードを最適化してください。 2)0.5秒ごとにテーブルを再使用しないでください。 3)セルに更新ラベルがある場合は、そのセル内でラベルを更新します。 4)あなたが何を表示するかについてのより多くの情報が必要です(画像/テキスト/ etc) –