Подтвердить что ты не робот

Я не хочу, чтобы анимация начала обновления, завершает блок обновлений для uitableview?

У меня есть UITableView. Он использует пользовательскую ячейку таблицы, и каждая ячейка имеет uiwebview. Bcoz UIWebView взял время, чтобы загрузить, я хочу, чтобы избежать перезагрузки их любой ценой. В некоторых ситуациях у меня загружены все ячейки, но их высоты перепутаны. Поэтому мне нужно "ретранслировать" таблицу, не вызывая функцию "cellForRow".

  • Я определенно не могу использовать reloadData... поскольку он снова перезагрузит ячейки.
  • Я попробовал tableView.setNeedDisplay, setNeedsLayout и т.д., ни один из них не может изменить ячейки таблицы.
  • Единственный способ, с помощью которого он работал, - вызвать блок beginupdates/endupdates, этот блок может передать мою таблицу без запуска cellForRow! НО, мне не нужна анимация! Этот блок создает эффект анимации, но я не хочу его...

Как я могу решить свою проблему?

4b9b3361

Ответ 1

[UIView setAnimationsEnabled:NO];
[tableView beginUpdates];
[tableView endUpdates];
[UIView setAnimationsEnabled:YES];

Ответ 2

Еще один способ сделать это с помощью блоков

Obj-C

[UIView performWithoutAnimation:^{
   [self.tableView beginUpdates];
   [self.tableView endUpdates];
}];

Swift

UIView.performWithoutAnimation {
    tableView.beginUpdates()
    tableView.endUpdates()   
}

Ответ 3

Swifties Для этого мне пришлось сделать следующее:

// Sadly, this is not as simple as calling:
//      UIView.setAnimationsEnabled(false)
//      self.tableView.beginUpdates()
//      self.tableView.endUpdates()
//      UIView.setAnimationsEnabled(true)

// We need to disable the animations.
UIView.setAnimationsEnabled(false)
CATransaction.begin()

// And we also need to set the completion block,
CATransaction.setCompletionBlock { () -> Void in
    // of the animation.
    UIView.setAnimationsEnabled(true)
}

// Call the stuff we need to.
self.tableView.beginUpdates()
self.tableView.endUpdates()

// Commit the animation.
CATransaction.commit()

Ответ 4

Я предпочитаю плавный переход:

CGPoint offset = self.tableView.contentOffset;
[UIView transitionWithView:self.tableView duration:0.5 options:UIViewAnimationOptionTransitionCrossDissolve animations:^{
        [self.tableView reloadData];
        self.tableView.contentOffset = offset;
    } completion:nil];

попробуйте.

Ответ 5

Я хотел обновить высоту ячейки для раздела 5 и следующий код работал у меня:

UiView.setAnimationsEnabled(False)
self.productTableView.reloadSections(NSIndexSet(index: SectionType.ProductDescription.hashValue), withRowAnimation: UITableViewRowAnimation.None)
self.productTableView.scrollToRowAtIndexPath(NSIndexPath(forRow: 0, inSection: 5), atScrollPosition: UITableViewScrollPosition.Bottom, animated: false)
UIView.setAnimationsEnabled(true)