ios - 从 UILongPressGestureRecognizer 中的每个触摸获取坐标

标签 ios objective-c cocoa-touch uigesturerecognizer

我有一个 UILongPressGestureRecognizer 设置为 numberOfTouchesReguired = 2。如何获取每个手指在 View 上的连续坐标?

目前我有这个,但它似乎将所有触摸的位置合并为 1 个坐标。

- (void)handleLongPress:(UILongPressGestureRecognizer *)sender {
    CGPoint locationInView = [sender locationInView:nil];
}

最佳答案

请参阅 UIGestureRecognizer 的文档。它为此提供了方法:

- (void)handleLongPress:(UILongPressGestureRecognizer *)sender {
    if (sender.state == UIGestureRecognizerStateChanged) {
        NSUInteger *touchCount = [sender numberOfTouches];
        for (NSUInteger t = 0; t < touchCount; t++) {
            CGPoint point = [sender locationOfTouch:t inView:sender.view];
        }
    }

关于ios - 从 UILongPressGestureRecognizer 中的每个触摸获取坐标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15318004/

相关文章:

objective-c - UITableView 设置选中行刷新控件

ios - 什么时候应该将 layer.shouldRasterize 设置为 YES

ios - 更新时应用程序崩溃

ios - ios 8.3 显示 alertview 时键盘会自动出现

iphone - 如何在 Xcode 中显示/隐藏 View

ios - 应用程序崩溃异常类型 : EXC_CRASH (SIGKILL) Termination Reason: Namespace SPRINGBOARD

ios - 为 'CONTAINED_BY' 文本查询编写一个 NSPredicate

objective-c - 如何用Objective-C构造一个trie数据结构?

iphone - 以所选格式获取 iPhone 上的当前时间

iphone - iOS - UIProgressView 只更新一次