iOS UITableViewCell 需要按两次才能调用 didSelectRowAtIndexPath [英] iOS UITableViewCell needs to be pressed twice to call didSelectRowAtIndexPath

查看:57
本文介绍了iOS UITableViewCell 需要按两次才能调用 didSelectRowAtIndexPath的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 UITableView,有时需要你触摸它两次才能选择一个单元格.

I have a UITableView that sometimes requires you touch it twice to select a cell.

更多细节:

  • 只有在表格一直向上或向下滚动后才需要触摸两次.
  • 只有第二次触摸才会调用 didSelectRowAtIndexPath.
  • 当表格以自然的向上滚动位置"打开时,只需轻轻一按即可选择单元格.
  • 如果您只滚动一点(不是一直向下/向上),只需轻轻一按,单元格就会被选中.
  • 如果单元格没有填满整个表格并且不需要滚动,它就可以正常工作.
  • 一直到顶部或底部,您必须触摸两次.

我有一种感觉,第一次触摸确实使 UITableViewCells 可选或以某种方式激活表格.

I have a feeling that the first touch is really making the UITableViewCells selectable or is activating the table in some way.

我检查过的东西:

  • 我的代码绝对不会在任何地方调用 didDeselectRowAtIndexPath.
  • 没有 UIGestureRecognizers 正在使用 setCancelsTouchesInView:.
  • My code definitely doesn't call didDeselectRowAtIndexPath anywhere.
  • No UIGestureRecognizers are using setCancelsTouchesInView:.

表上的其他设置:

self.tableView.scrollEnabled = YES;
self.tableView.showsVerticalScrollIndicator = NO;
self.tableView.bounces = NO;
self.tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;

这是什么原因?

奇怪的是,设置 self.tableView.bounces = YES; 解决了这个问题.

Oddly enough, setting self.tableView.bounces = YES; fixed the problem.

我仍在寻找根本原因,以防万一有人有更好的答案.显然,我希望桌子不会弹跳,但如果它会影响关键功能,则不会.

I am still looking into the root cause in case anyone has a better answer. Obviously I would like for the table not to bounce, but not if it costs key functionality.

推荐答案

可能你实现了 didDeselect 而不是 didSelect?

May be you implemented didDeselect instead of didSelect?

这篇关于iOS UITableViewCell 需要按两次才能调用 didSelectRowAtIndexPath的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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