gpt4 book ai didi

ios - UIPanGestureRecognizer : Why there is no StateEnded every time

转载 作者:行者123 更新时间:2023-11-29 02:46:47 25 4
gpt4 key购买 nike

我正在使用 UIPanGestureRecognizer 来检测和计算手指的移动。我的问题是触发了以下事件序列:

状态开始状态改变状态改变状态改变状态结束

但有时同一用户交互只有这个序列

状态改变状态改变状态改变

- (void)viewDidLoad
{
UIPanGestureRecognizer *panRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panHandler:)];
panRecognizer.minimumNumberOfTouches = 1;
panRecognizer.maximumNumberOfTouches = 1;
[panRecognizer setDelaysTouchesBegan:NO];
[panRecognizer setDelaysTouchesEnded:NO];
[self.view addGestureRecognizer:panRecognizer];
}

-(void)panHandler:(UIPanGestureRecognizer *)recognizer {
//gesture hanlding here
if(recognizer.state == UIGestureRecognizerStateEnded){
// Do smth here
}
}

最佳答案

因为可以取消。来自文档:

Possible ----> Began ----> [Changed] ----> Cancelled
Possible ----> Began ----> [Changed] ----> Ended

https://developer.apple.com/library/ios/documentation/uikit/reference/UIGestureRecognizer_Class/Reference/Reference.html#//apple_ref/doc/uid/TP40009279-CH1-DontLinkElementID_2

关于ios - UIPanGestureRecognizer : Why there is no StateEnded every time,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25016983/

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