Advertisement
Guest User

Untitled

a guest
Jul 15th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 1.58 KB | None | 0 0
  1. // Вариант №1 (анимация не работает)
  2.    func didTapOnCustomTableViewCell(sender: CustomTableViewCell) {
  3.         guard let indexPath = tableView.indexPath(for: sender) else {
  4.             return
  5.         }
  6.         CATransaction.begin()
  7.         CATransaction.setCompletionBlock({ [weak self] in
  8.             guard let indexPath = self?.tableView.indexPath(for: sender) else {
  9.                 return
  10.             }
  11.             guard let cell = self?.tableView.cellForRow(at: indexPath) as? CustomTableViewCell else {
  12.                 return
  13.             }
  14.             cell.launchAnimation()
  15.         })
  16.         tableView.beginUpdates()
  17.         tableView.reloadRows(at: [indexPath], with: .none)
  18.         tableView.endUpdates()
  19.         CATransaction.commit()
  20.    }
  21.  
  22.    // Вариант №2 (а так работает!!!) Спасибо!
  23.    func didTapOnCustomTableViewCell(sender: CustomTableViewCell) {
  24.         guard let indexPath = tableView.indexPath(for: sender) else {
  25.             return
  26.         }
  27.         CATransaction.begin()
  28.         CATransaction.setCompletionBlock({ [weak self] in
  29.             // guard let indexPath = self?.tableView.indexPath(for: sender) else {
  30.             //    return
  31.             // }
  32.             guard let cell = self?.tableView.cellForRow(at: indexPath) as? CustomTableViewCell else {
  33.                 return
  34.             }
  35.             cell.launchAnimation()
  36.         })
  37.         tableView.beginUpdates()
  38.         tableView.reloadRows(at: [indexPath], with: .none)
  39.         tableView.endUpdates()
  40.         CATransaction.commit()
  41.    }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement