Ответ 1
endUpdates
запускает пересчет размера содержимого, для которого требуется heightForRowAtIndexPath
. Вот как это работает.
Если это проблема, вы можете вывести логику конфигурации вашей ячейки за пределы cellForRowAtIndexPath
и перенастроить ячейку напрямую, не пройдя через reloadRowsAtIndexPaths
. Вот базовый план того, как это может выглядеть:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *cellId = ...;
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
if (!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellId];
}
[self tableView:tableView configureCell:cell atIndexPath:indexPath];
return cell;
}
- (void)tableView:(UITableView *)tableView configureCell:(UITableViewCell *)cell atIndexPath:(NSIndexPath *)indexPath
{
//cell configuration logic here
}
Затем, когда вы в настоящее время вызываете reloadRowsAtIndexPaths
, вы делаете это вместо этого, а heightForRowAtIndexPath
не будет вызываться:
UITableViewCell *cell = [self.messageTableView cellForRowAtIndexPath:indexPath];
[self tableView:self.messageTableView configureCell:cell atIndexPath:indexPath];