gpt4 book ai didi

ios - UITableViewController 的 didSelectRowAtIndexPath 不起作用

转载 作者:可可西里 更新时间:2023-10-31 23:58:39 24 4
gpt4 key购买 nike

我正在为其使用 UITableViewController 并且我重写了以下方法并尝试在用户选择不同的行时启用不同的 segues。

func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
print("You selected row #\(indexPath.row)!")
switch indexPath.row {
case 3:
performSegue(withIdentifier: "segue3", sender: self)
case 8:
performSegue(withIdentifier: "segue8", sender: self)
default:
break
}
}

但实际上,这个方法永远不会被调用,当我选择一行时,打印输出也永远不会出现。

我确实启用了单选,启用了用户交互并将委托(delegate)和数据源设置为 Controller 本身(使用 UITableViewController 时会自动设置,对吧?)

我正在使用静态单元格和默认的 UITableViewCell。 View Controller 是 UITableViewController

enter image description here

更新:

我尝试替换:

func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: IndexPath) 

与:

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)

这也行不通。

最佳答案

对于 swift 3

override  func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath){
// your code ...
}

还有一件事要确保您的 tableView single selection 属性被选中 ...

关于ios - UITableViewController 的 didSelectRowAtIndexPath 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45135212/

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