Xcode 8/Swift 3:didSelectRowAt 与 didSelectRowAtIndexPath [英] Xcode 8 / Swift 3: didSelectRowAt vs didSelectRowAtIndexPath
问题描述
在我们的 Swift 3 迁移之后发生了一些非常奇怪的事情.我们有两个视图控制器,它们都实现了 UITableViewDelegate
并且它们都实现了 public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)
Something really weird is going on after our Swift 3 migration.
We have two view controllers, both of them implement UITableViewDelegate
and both of them implement public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)
但是只有在其中一个中调用了实际的方法.
However only in one of them the actual method is called.
如果我将不起作用的 public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)
更改为 public func tableView(_ tableView: UITableView, didSelectRowAtIndexPath:IndexPath)
(注意 Swift 2.2 签名)然后它们都可以工作.
If I change in the one that doesn't work public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)
to public func tableView(_ tableView: UITableView, didSelectRowAtIndexPath: IndexPath)
(notice the Swift 2.2 signature) then they both work.
两个视图控制器都是 Swift 类,所以我不确定到底发生了什么.我很确定这可能是 Objective-C 与 Swift 的互操作性问题,但我们的整个项目都是用 Swift 编写的,因此很难找出导致这种情况的原因.
Both view controllers are Swift classes, so I am not sure what the heck is going on. I am pretty sure it might be a Objective-C vs Swift interoperability issue, but our whole project is written in Swift, so that's why it's hard to figure out what is causing this.
感谢任何帮助.谢谢.
推荐答案
对于 Swift 3.0,使用
for Swift 3.0, use
override func tableView(_ tableView: UITableView, didSelectRowAt
indexPath: IndexPath){
//your code...
}
这篇关于Xcode 8/Swift 3:didSelectRowAt 与 didSelectRowAtIndexPath的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!