为什么UIPinchGestureRecognizer不会被调用,而scrollViewDidEndZooming会被调用?
我有一个 UIViewController,它使用 UIScrollView,在该 Scrollview 中它有一个 UIImageView。
我想识别捏合并相应地缩放。我不需要缩放,我只需要显示不同的图像。
它看起来很像这个问题:UIView UIPinchGestureRecognizer问题
我尝试了几件事:
设置contentMode将
UIViewContentModeScaleAspectFit
设置
multipleTouchEnabled = YES
设置
userInteractionEnabled = YES
然而,它仍然不能总是捕获捏合事件。
以下是我如何将手势分配给视图,非常简单:
UIPinchGestureRecognizer *pinchRecognizer = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(zoomPinch:)];
[MediaScroller addGestureRecognizer:pinchRecognizer];
[pinchRecognizer release];
此外,我确实注意到我的委托调用了 scrollViewDidEndZooming
,但比例变量始终为 1.0。怎么可能呢?
scrollViewDidEndZooming
始终被调用,而捏合方法 (zoomPinch) 并不总是被调用。有什么原因会发生这种情况吗?我该如何解决它? :)
I have a UIViewController, which uses a UIScrollView and within that Scrollview it has a UIImageView.
I want to recognize a pinch and zoom accordingly. I don't need to scale, i just need to show a different image.
It pretty much looks like this question: UIView UIPinchGestureRecognizer problem
I have tried several things:
set contentMode to
UIViewContentModeScaleAspectFit
set
multipleTouchEnabled = YES
set
userInteractionEnabled = YES
And yet, it still not always catches the pinching event.
Here is how I assign the gesture to the view, pretty straightforward:
UIPinchGestureRecognizer *pinchRecognizer = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(zoomPinch:)];
[MediaScroller addGestureRecognizer:pinchRecognizer];
[pinchRecognizer release];
Also, I do notice that the scrollViewDidEndZooming
is called of my delegate, but the scale variable is always 1.0. How can that be?
The scrollViewDidEndZooming
is always called, while the pinch method (zoomPinch) is not always called. Any reasons why that would happen? And how can I fix it? :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我相信您需要在您的识别器委托中实现这一点:
然后,在自身类上:
由于该类已经识别捏合(用于缩放),因此您可能需要启用多个捏合处理程序。
I believe you need to implement this in your
recognizer delegate
:then, on self class:
As the class already recognizes pinch (for zoom), maybe you need to enable to have more than one handler for pinch.