第二次点击后有时会调用UITableView didSelectRowAtIndexPath

我正面临一个好奇的UITableView行为,我不知道它来自何处。 我正在构建一个非常简单的单视图IOS8 Swift应用程序,第一个ViewController里面有一个UITableView ,还有一个自定义Image单元。 当我点击一个单元格时,它会查看我的SecondViewController

我的UITableView委托和数据源连接到第一个ViewController。 一切都在工作,除非我点击一个单元格,有时我必须点击它两次才能触发Segue。

这是我的didSelectRowAtIndexPath函数:

 func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { println("You clicked on \(indexPath.row) row") self.performSegueWithIdentifier("homeToDetail", sender:self) } 

我的打印始终返回正确的indexPath。 它是一个视图层次结构问题还是其他什么?

谢谢JD

尝试这个。

 func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { dispatch_async(dispatch_get_main_queue(), { self.performSegueWithIdentifier("homeToDetail", sender:self) }) } 

我认为这是iOS 8中的一个错误。 UITableViewCell选择故事板segue很慢 – 虽然双击是有效的

你必须调用[tableView deselectRowAtIndexPath:indexPath animated:YES]; 解决这个问题