这是一个奇怪的。
<<p>上下文/strong>- MainViewController (
UIViewController
, NOT aUITableViewController
)与UITableView
和UIView
包含一些按钮 - tableView使用
NSFetchedResultsController
填充,委托为MainViewController - DetailsViewController在tableView上被推送(没有segue) didSelectRow
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let document = CoreDataManager.shared.frc.object(at: indexPath)
// Pass model
self.detailsVC.model = model
self.navigationController?.pushViewController(self.detailsVC, animated: true)
}
当导航回MainViewController时,我无法让选定的行动画。它会被正确地取消选择。
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
// Deselect selected row
if let indexPath = tableView.indexPathForSelectedRow {
tableView.deselectRow(at: indexPath, animated: true) // animated flag is set to true... to normally get an animation
}
}
我已经试过了
- 取消
viewWillAppear
—>同样的结果,取消选择OK,动画不OK - 确保没有tableView.reloadData()发生
额外信息
我刚刚发现,选择动画也不工作。在iOS 13上运行良好。
我不知道该怎么办了。我希望在导航返回时能有通常的漂亮动画(例如:联系人应用程序)。谢谢!
确保单元格的selectionStyle
属性没有设置为.none
。