gpt4 book ai didi

iphone - iOS 中的两指滑动与一指拖动

转载 作者:行者123 更新时间:2023-11-28 17:44:49 30 4
gpt4 key购买 nike

在我的应用程序中,我有一个 UIView 派生类 Canvas,它使用 touchesBegan: withEvent:touchesMoved: withEvent:touchesEnded: withEvent: 在 Canvas 中绘制。我还想使用滑动来加载数组中的上一个(或下一个) Canvas 。我尝试设置以下手势(和右侧的类似手势):

UISwipeGestureRecognizer* leftSwipe = [[UISwipeGestureRecognizer alloc] initWithTarget: self action: @selector(pageFlipNext)];
leftSwipe.direction = UISwipeGestureRecognizerDirectionLeft;
leftSwipe.numberOfTouchesRequired = 2;
[_canvas addGestureRecognizer: leftSwipe];
[leftSwipe release];

但我的两指滑动仍被视为单指绘图指令。如何让我的应用程序正确处理双指滑动?

最佳答案

首先,我将开始验证 _canvas.multipleTouchEnabled 是否设置为 YES。如果不是,请将其设置为 YES

你可能还想考虑一下

leftSwipe.delaysTouchesBegan = YES;

这将延迟发送到 _canvas 的触摸,直到手势失败。您还可以使用 UIPanGestureRecognizer 并执行类似这样的操作,

[pan requireGestureRecognizerToFail:leftSwipe];

关于iphone - iOS 中的两指滑动与一指拖动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6593289/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com