ios - UITapGestureRecognizer 是如何感知上下触摸的?

标签 ios uitableview uitapgesturerecognizer

我有一个包含项目行的 TableView 。我还在其上附加了一个 UITapGestureRecognizer,以便让我的 Controller 处理点击项目行中的自定义按钮。我的问题是,我想应用详细的效果来触摸和触摸按钮。我尝试使用 UILongPressGestureRecognizer 而不是 UITapGestureRecognizer 并将 minimumPressDuration 设置为 0.0f。它有效,但它导致 TableView 无法滚动。请帮忙,谢谢。

最佳答案

如果您只需要将点击监听器附加到表格行中的按钮,我建议您删除 UITapRecognizer,并将选择器添加到每个事件所需的按钮。

[btn addTarget:self action:@selector(touchedUp) forControlEvents:UIControlEventTouchUpInside];

[btn addTarget:self action:@selector(touchedDown) forControlEvents:UIControlEventTouchDown];

关于ios - UITapGestureRecognizer 是如何感知上下触摸的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17519161/

相关文章:

ios - 使用具有动态高度的 UIScrollView 时使 View 在屏幕上居中

ios - 滑动删除时如何让tableViewCell不展开

ios - 夹在 willBeginEditingRowAtIndexPath 和 didEndEditingRowAtIndexPath 之间

ios - 在具有 UIGestureRecognizer 的 View 中时,不会调用 UIBarButtonItem 的操作

iphone - 如何使用 UITapGestureRecognizer 同时检测点击和双击?

ios - 未调用 UISwipeGestureRecognizer UIGestureRecognizerStateChanged

ios - Xcode 4.2 UITableViewCell 背景

ios - CGPoint 的索引路径

ios - 使用 UITapGestureRecognizer 显示 UIPickerView

javascript - 在 iPad 中隐藏地址栏