Advertisement
Guest User

Untitled

a guest
Jul 15th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 1.27 KB | None | 0 0
  1.     // метод делегата ячейки (вызывется при тапе на view ячейки)  CustomTableViewCell
  2.     // вариант №1 (анимация не проигрывается, хотя программа в метод успешно cell.launchAnimation() заходит)
  3.     func didTapOnTableViewCellView(sender: CustomTableViewCell) {
  4.         guard let indexPath = tableView.indexPath(for: sender) else {
  5.             return
  6.         }
  7.         guard let cell = tableView.cellForRow(at: indexPath) as? CustomTableViewCell else {
  8.             return
  9.         }
  10.         CATransaction.begin()
  11.         CATransaction.setCompletionBlock({
  12.             cell.launchAnimation()
  13.         })
  14.         tableView.beginUpdates()
  15.         tableView.reloadRows(at: [indexPath], with: .none)
  16.         tableView.endUpdates()
  17.         CATransaction.commit()
  18.     }
  19.  
  20.     // вариант №2 (анимация проигрывается)
  21.  
  22.     func didTapOnTableViewCellView(sender: CustomTableViewCell) {
  23.         guard let indexPath = tableView.indexPath(for: sender) else {
  24.             return
  25.         }
  26.         guard let cell = tableView.cellForRow(at: indexPath) as? CustomTableViewCell else {
  27.             return
  28.         }
  29.         cell.launchAnimation()
  30.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement