ios – 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 selection Storyboard segue is slow – double tapping works though

相关文章

UITabBarController 是 iOS 中用于管理和显示选项卡界面的一...
UITableView的重用机制避免了频繁创建和销毁单元格的开销,使...
Objective-C中,类的实例变量(instance variables)和属性(...
从内存管理的角度来看,block可以作为方法的传入参数是因为b...
WKWebView 是 iOS 开发中用于显示网页内容的组件,它是在 iO...
OC中常用的多线程编程技术: 1. NSThread NSThread是Objecti...