【发布时间】:2021-02-16 16:08:33
【问题描述】:
编辑: 我没有意识到是动画(在故事板中的 segue 中)和 pushViewController() 中的动画完成了这项工作。
当我们点击表格视图中的一行时,如何平滑过渡到下一个视图。我想实现与苹果的设置应用类似的平滑过渡效果。现在,只要触摸行,我的转换就会立即发生。
在 Apple 的设置应用程序中,当您点击设置菜单上的一行时,它首先会突出显示该行,然后平滑过渡到下一个视图。这就是我想要达到的目标。
我已搜索但找不到任何相关的解决方案。有什么帮助吗?
以下是我的行选择代码
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let cell = tableView.cellForRow(at: indexPath)
tableView.deselectRow(at: indexPath, animated: true)
//.....
self.navigationController?.pushViewController(destinationVC, animated: false)
}
【问题讨论】:
-
你看过
UINavigationController?和pushViewController(_ :animated:)吗? -
您需要发布用于执行转换的代码。
-
我已经用相关代码更新了我的问题。
-
@EmilioPelaez 我相信他想要
UINavigationController提供的动画。 -
@ParthTamane。好的,是 UINavigationController 提供了这个动画。如果我们不使用 UINavigationController 会怎样?在这种情况下也能达到同样的效果吗?
标签: ios swift uitableview uitableviewrowaction