第二次点击后有时会调用UITableView didSelectRowAtIndexPath [英] UITableView didSelectRowAtIndexPath sometimes called after second tap

查看:133
本文介绍了第二次点击后有时会调用UITableView didSelectRowAtIndexPath的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm facing a curious UITableView behaviour and i don't know where this is coming from. I'm building a very simple single view IOS8 Swift application with a first ViewController with a UITableView inside it and one custom Image cell. When i tap on a cell it Segue to my SecondViewController.

我的UITableView委托和数据源连接到第一个视图控制器。
一切正常,除非我点击一个单元格,有时我必须点击两次以触发Segue。

My UITableView delegate and datasource is connected to the first ViewController. Everything is working except when i tap a cell sometimes i have to tap it twice to trigger the Segue.

这是我的 didSelectRowAtIndexPath function:

Here is my didSelectRowAtIndexPath function:

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

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

My print is always returning the correct indexPath. Is it a view hierarchy problem or something else ?

谢谢你JD

推荐答案

试试这个。

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

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

This is a bug in iOS 8, I think. UITableViewCell selection Storyboard segue is slow - double tapping works though

这篇关于第二次点击后有时会调用UITableView didSelectRowAtIndexPath的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆