平移和 2 指捏合同步 iOS -同时 -
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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您似乎没有为每个手势识别器设置委托。
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.您是否将自己设置为识别者代表?
PS 我还尝试为您的变量获得更一致的命名方案!
Are you setting yourself as the recognisers delegate?
PS I'd also try to get a more consistent naming scheme for your variables!