ios - 如何在选择 tableviewcell 时运行函数(例如,按下单元格时更新 UIImageView)

标签 ios swift uitableview uiimageview

我正在制作一个具有集合 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/

相关文章:

ios - 了解 iOS Swift 中的 CoreData

ios - 尝试阻止抛出错误

iphone - 刷新CoreData表?

Swift 3 在 For 循环中排除项目

ios - UITableViewCell 重用自定义 UIView 作为组件导致 "caching"问题

ios - 在 Ios 中,当项目源在 xamarin.forms 中更新时,ListView 会自动滚动到顶部。在ios中保持滚动位置

iphone - 从 iPhone 登录 : where is the file?

ios - 有没有更短的方法来使用 indexPath.row?

javascript - 在 IOS 上的 Safari/Chrome 中无法使用 Cache-API,对吗?

iphone - 双分屏