Swift DidSelectRowAt 不触发 [英] Swift DidSelectRowAt not firing

查看:34
本文介绍了Swift DidSelectRowAt 不触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个项目有几个不同的 VC...其中两个有 TableViews

I have a project with a few different VCs...two of them have TableViews

第一个工作得很好,我在那里有一个自定义视图等.

The first one works perfectly fine, I have a custom view in there etc.

第二个也是自定义的,它填写的信息很好,但与第一个不同......我无法点击它来继续下一个 VC

The second one is also custom and it fill the information in just fine, but unlike the first one...I cannot tap on it to segue to the next VC

我已经正确设置了委托和数据源.我的项目中有另一个带有 tableview 的 VC,它工作得很好.我认为可能会阻止它工作的第一件事是 UILabel 占据了 90% 的单元格,但我不认为是这样,因为我把标签弄小了,然后尝试点击,但它仍然不会击中断点.

I have the Delegate and DataSource set up properly. I have another VC on my project with a tableview and it works just fine. The first thing I can think might be preventing it from working is a UILabel takes up 90% of the cell, but I don't think that is it because I made the label small and tried tapping then and it still wouldn't hit the breakpoint.

      func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {

    let row = indexPath.row

    selectedService = serviceArray[row].serviceID! as String

    if selectedService != "" {

      self.performSegue(withIdentifier: "fromCardDetailsToEditService", sender: self)

    }
  }

我不知道这是否重要,但是……我使用的 VC 位于 Tab Bar Controller 和 Nav Bar Controller 中.我在标签栏中对 performSegue 有影响吗?而且这个按钮不是标签栏项目?

I do not know if it matters BUT...the VC that I am on is in a Tab Bar Controller and a Nav Bar Controller. Does it matter for the performSegue that I am in a Tab Bar? And that this button is not a tab bar item?

推荐答案

你的 UIViewController 上是否有任何 GestureRecognizer 因为在 GestureRecognizer 的情况下> tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) 没有调用.

Did you have any GestureRecognizer on your UIViewController because in case of GestureRecognizer tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) does not called.

这篇关于Swift DidSelectRowAt 不触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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