【问题标题】:select UITableView cell with uitableviewcellselectionstylenone使用 uitableviewcellselectionstylenone 选择 UITableView 单元格
【发布时间】:2012-01-16 16:34:14
【问题描述】:

我在创建单元格时在单元格上设置了 uitableviewcellselectionstylenone。长按需要精确选择单元格,可以吗?

【问题讨论】:

  • 您可以添加一个手势识别器,或者创建一个自定义单元格,它不会在点击时绘制蓝色突出显示但仍会发送“did select”委托调用。

标签: objective-c uitableview


【解决方案1】:

UILongPressGestureRecognizer 添加到表中。您可以拨打indexPathForRowAtPoint查找用户长按的单元格。

CGPoint p = [gestureRecognizer locationInView:self.myTableView];
NSIndexPath *indexPath = [self.myTableView indexPathForRowAtPoint:p];

有关完整示例,请参阅 the accepted answer to this question

【讨论】:

  • 也可以使用[self.tableView indexPathForCell:cell]获取索引路径
  • @hypercrypt 但我在手势识别器的回调中没有单元格:它给我的只是一个触摸点。
猜你喜欢
  • 2011-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-10-20
  • 2011-08-04
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多