如何用两根手指而不是一根手指实现传统的 imageView-inside-a-scrollView 平移手势?

发布于 2024-10-26 14:02:19 字数 281 浏览 0 评论 0原文

我有一个嵌套在滚动视图中的 imageView,它允许我查看图像、捏合缩放以及在放大到足够大时平移。使用自定义 GestureRecognizer,我(根据我为其构建此应用程序的人的请求)覆盖了单指平移的默认行为,以便它执行平移以外的操作。这非常有效。

现在的问题是,我仍然需要能够像用一根手指平移一样平移图像,我现在只需要用两根手指即可。是否有一个解决方案可以实现利用嵌套 imageView 的现有功能?或者我是否需要在识别两个手指手势后编写我自己的自定义泛逻辑?

非常感谢这里的任何想法!

谢谢

I have an imageView nested inside of a scrollView that allows me to view an image, pinch to zoom, and pan around if I am zoomed in enough. Using a custom GestureRecognizer, I have (per the request of the person I'm building this app for) overridden the default behavior of the one finger pan so that it does something other than pan. This works perfectly.

Now the problem is that I still need the ability to pan around the image like I could with the one finger pan, I just need this to now be with two fingers. Is there a solution that can be implemented to utilize the already available features of the nested imageView? Or do I need to go through and after the two finger gesture is recognized, write my own custom pan-logic?

Any thoughts here are greatly appreciated!

Thanks

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

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

发布评论

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

评论(1

叶落知秋 2024-11-02 14:02:19

对于较新版本的 iOS,您只需调整已附加到滚动视图的“默认”UIPanGenstureRecognizer 的参数

    for (UIGestureRecognizer *gestureObj in scrollView.gestureRecognizers) {
    if ([gestureObj isKindOfClass:[UIPanGestureRecognizer class]])
    {
        UIPanGestureRecognizer *panObj = (UIPanGestureRecognizer *) gestureObj;
        panObj.minimumNumberOfTouches = 2;
        panObj.maximumNumberOfTouches = 2;
    }
}

,这应该将行为“转移”到 2 手指级别

With the newer versions if iOS you can merely adjust the parameters of the 'default' UIPanGenstureRecognizer that is already attached to the scrollView

    for (UIGestureRecognizer *gestureObj in scrollView.gestureRecognizers) {
    if ([gestureObj isKindOfClass:[UIPanGestureRecognizer class]])
    {
        UIPanGestureRecognizer *panObj = (UIPanGestureRecognizer *) gestureObj;
        panObj.minimumNumberOfTouches = 2;
        panObj.maximumNumberOfTouches = 2;
    }
}

That should 'shift' the behavior to the 2 finger level

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