平移和 2 指捏合同步 iOS -同时 -

发布于 2024-12-19 23:09:30 字数 697 浏览 4 评论 0原文

2 手势识别器:

UIPinchGestureRecognizer *twoFingerPinch = 
[[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(handlePinch:)];
[croppper addGestureRecognizer:twoFingerPinch];

UIPanGestureRecognizer *PanRecognizer = [[[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePan:)] autorelease];
[croppper addGestureRecognizer:PanRecognizer];

并且:

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {        
    return YES;
}   

但是同时捏合和平移不起作用...... 通常我可以捏,因为平底锅识别器已打开。

问候

2 Gesture recognizer:

UIPinchGestureRecognizer *twoFingerPinch = 
[[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(handlePinch:)];
[croppper addGestureRecognizer:twoFingerPinch];

UIPanGestureRecognizer *PanRecognizer = [[[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePan:)] autorelease];
[croppper addGestureRecognizer:PanRecognizer];

and:

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {        
    return YES;
}   

But pinch and pan at the same time is not working...
often i can pinch because the pan recognizer is on.

regards

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

计㈡愣 2024-12-26 23:09:30

您似乎没有为每个手势识别器设置委托。 gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer: 是一个委托方法,因此如果手势识别器没有委托,则不会调用此方法。

因此,默认返回值为 NO,因此手势不会同时被识别。

It doesn't look like you're setting the delegate for each gesture recognizer. gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer: is a delegate method, and so if the gesture recognizer has no delegate, this method won't be invoked.

As a result, the default return value will be NO, and so the gestures won't be recognised simultaneously.

不喜欢何必死缠烂打 2024-12-26 23:09:30

您是否将自己设置为识别者代表?

[twoFingerPinch setDelgate:self];
...
[PanRecognizer setDelegate:self];

PS 我还尝试为您的变量获得更一致的命名方案!

Are you setting yourself as the recognisers delegate?

[twoFingerPinch setDelgate:self];
...
[PanRecognizer setDelegate:self];

PS I'd also try to get a more consistent naming scheme for your variables!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文