gpt4 book ai didi

ios - 来自 uitableViewCell 的 swift @IBAction

转载 作者:行者123 更新时间:2023-11-29 00:09:48 24 4
gpt4 key购买 nike

我需要通过单击 tableViewCell 来触发函数,到目前为止我使用@IBAction,但该选项仅适用于按钮类型(我还没有找到其他方法..)这是我现在的方式:

@IBAction func springPrs(_ sender: Any) {
//doing stuff..
}

但现在我有一个@IBOutlet

@IBOutlet weak var nextTrackCell: nextTableViewCell!

我想通过点击它来触发一个功能。有帮助吗?

最佳答案

这是一种错误的方法,您应该从 UITableViewDelegate 中实现一个名为 didSelectRowAt 的委托(delegate)方法:

  public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
//do your stuff here.
}

关于ios - 来自 uitableViewCell 的 swift @IBAction,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46828214/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com