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

标签 ios iphone uitableview swift segue

我正面临一个奇怪的 UITableView 行为,我不知道这是从哪里来的。 我正在构建一个非常简单的单一 View IOS8 Swift 应用程序,第一个 ViewController 里面有一个 UITableView 和一个自定义图像单元格。当我点击一个单元格时,它会转到我的 SecondViewController

我的 UITableView 委托(delegate)和数据源连接到第一个 ViewController。 一切正常,除了当我点击一个单元格时,有时我必须点击它两次才能触发 Segue。

这是我的 didSelectRowAtIndexPath 函数:

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

我的打印总是返回正确的 indexPath。 是 View 层次结构问题还是其他问题?

谢谢京东

最佳答案

试试这个。

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

关于ios - 第二次点击后有时会调用 UITableView didSelectRowAtIndexPath,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27906793/

相关文章:

ios - 为什么 CGRectInfinite 和所有成员都设置为 INFINITY 的 CGRect 之间存在差异?

ios - iOS应用程序同一工作区内多个项目的xcode 4静态库链接

ios - 获取当前位置但只有一次

ios - 设置UIlabel的高度

objective-c - 进入编辑模式时保持 UITableViewCell 背景颜色

ios - Xcode 6 - 无法从方法返回 UIImage

ios - ScrollView Layout Direction 如何在 SwiftUI 中从右到左?

iphone - 优化此核心数据请求

iphone - 作为团队管理员如何使用 Adhoc 分发?

ios - 如何从 TableView 行和核心数据实体中删除数据?