objective-c - UISwipeGestureRecognizer 适用于触摸 1 和 2,但不适用于触摸 3

标签 objective-c ios uiswipegesturerecognizer

以下内容不起作用 - handleSwipeUpTriple 从未被调用:

- (BOOL) application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {  
    UISwipeGestureRecognizer *swipeUpTripleRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeUpTriple:)];
    swipeUpTripleRecognizer.direction = UISwipeGestureRecognizerDirectionUp;
    swipeUpTripleRecognizer.numberOfTouchesRequired = 3; // triple finger
    // window is in nib
    [self.window addGestureRecognizer:swipeUpTripleRecognizer];
    [swipeUpTripleRecognizer release];
}

- (void) handleSwipeUpTriple:(UISwipeGestureRecognizer *)sender {
    printf("\nhandleSwipUpTrpl called."); // never happens
    if (sender.state == UIGestureRecognizerStateEnded) 
        printf("\n SwipeUpTriple recognized.");
}

奇怪的是,如果我将 numberOfTouchesRequired 更改为 1 甚至 2,它就会起作用。似乎只有 3(或 4)根手指是出界的。由于我看到很多有关三指手势的帖子,所以我不明白为什么会这样。

self.window.multipleTouchEnabled 为"is"。

出于测试目的,我删除了所有 subview 。屏幕上除了 self.window 之外什么也没有。

我仍在使用 iOS 4.3,但由于 iOS 3.2 提供了 UISwipeGestureRecognizer,所以我不明白为什么这会成为问题。

最佳答案

我知道非 iPad 设备有时会运行 3 个手指的系统手势识别器(通常是缩放)。根据您的设置,系统可能会为自己保留这个数量的手指。

我们发现,您可以通过转到“常规”>“辅助功能”并禁用三指手势来解决此问题。

关于objective-c - UISwipeGestureRecognizer 适用于触摸 1 和 2,但不适用于触摸 3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11248806/

相关文章:

iphone - UILongPressGestureRecognizer 标签? - iPhone

ios - 进一步扩展可扩展表格 View 单元格

iPhone 5 屏幕截图未显示在 iPhone 5 App Store 上

php - Cocoa Mac App Webview session 丢失

ios - 如果出现标签栏,则无法调整搜索结果 Controller View 底部内容插图

ios - 使用执行选择器但带有参数创建 SKAction

ios - UISwipeGestureRecognizers 不会被同时识别

ios - Storyboard:启用高级 UI 配置

ios - 在滚动到顶部的 UITextView 上检测向下滑动

ios - 通过 subview 移动一个正方形