我正在制作一个具有集合 TableView 的应用程序,当选择一个单元格时,它会转入另一个具有 TableView 的 View Controller 。
我想使用这个 TableView 来更新我的 VC 中的 UIImageView。假设我在 TBC 上按“仰卧起坐”,我希望 ImageView 更新为显示仰卧起坐的动画。希望有人能理解我想要做什么,感谢您的帮助!
最佳答案
当点击单元格时,会调用委托(delegate)方法 tableView(_:didSelectRowAt:)
。
您可以在此方法中插入逻辑以连接到另一个 viewController
或更新同一 viewController
中的 imageView
。
对于 Swift 3.0:
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
//your code...
}
文档:https://developer.apple.com/reference/uikit/uitableviewdelegate/1614877-tableview
关于ios - 如何在选择 tableviewcell 时运行函数(例如,按下单元格时更新 UIImageView),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42850206/