【问题标题】:table view date selected only the long press表格查看日期只选择长按
【发布时间】:2017-07-19 12:50:02
【问题描述】:

我在Xib 中使用tableViewCell

在表格视图中,didSelectRowAt 函数仅在我长按tableViewCell 时被调用

我的代码在下面

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        categorytabelview.deselectRow(at: indexPath, animated: true)
        self.categorylabel.text = totalArrayofCars.object(at: indexPath.row) as? String
        categorytabelview.isHidden = true
    }

我想在单选中选择tabelViewCell 数据,而不是长按。

【问题讨论】:

  • 上面有没有添加手势识别器?
  • 不,我没有添加任何手势识别器
  • 为什么在选择单元格后取消选择行?
  • 是的,我评论了这一行 categorytabelview.deselectRow(at: indexPath, animated: true) 我运行我的代码,我得到了同样的错误
  • 你在使用第三方库吗?

标签: ios swift uitableview swift3


【解决方案1】:

由于您使用的是手势,所以在添加要查看的手势之前,添加以下行

tap.cancelsTouchesInView = false // assuming tap is your gesture recogniser variable

【讨论】:

  • 谢谢你们,我找到了解决方案。 tap.canceltouchInView = false 正在为我的下面工作,我的代码是 . ' 让 tapGesture = UITapGestureRecognizer(target: self, action: #selector(ADEditProfileVC.hidekeyboard)) tapGesture.cancelsTouchesInView = false tapGesture.numberOfTapsRequired = 1 view.addGestureRecognizer(tapGesture)'
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-01-26
  • 2014-11-30
  • 1970-01-01
  • 2018-03-27
  • 2014-04-22
  • 2021-09-27
相关资源
最近更新 更多