У меня есть tableView с расширяющимися ячейками. После расширения я хочу запустить анимацию, но я изо всех сил пытаюсь найти способ сделать это. Я пытался вызвать анимацию в awakeFromNib () в моем TableViewCell и didselectRowAt в моем ViewController. Поэтому, когда я расширяюсь в первый раз, анимация ничего не делает, но печатает оператор print «done», затем, если я сверну и разверну снова, анимация работает. Просто не работает с первого раза.
Это мой didSelectRowAt
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let cell = tableView.dequeueReusableCell(withIdentifier: "ContactNameCell") as? ContactNameTableViewCell
let socialCell = tableView.dequeueReusableCell(withIdentifier: "savedContactCell", for: indexPath) as? SavedContactTableViewCell
if tableViewData[indexPath.section].opened == true {
tableViewData[indexPath.section].opened = false
let sections = IndexSet.init(integer: indexPath.section)
contactsTableView.reloadSections(sections, with: .automatic)
} else {
tableViewData[indexPath.section].opened = true
let sections = IndexSet.init(integer: indexPath.section)
cell?.layoutIfNeeded()
contactsTableView.reloadSections(sections, with: .automatic)
cell?.layoutIfNeeded()
UIView.transition(with: (socialCell?.frontContactCard)!, duration: 0.4, options: [UIView.AnimationOptions.transitionFlipFromBottom, .autoreverse], animations: nil) { (success) in
// after completeion
print("done")
}
}
}