子视图在非 1:1 缩放/滚动视图上出现手势识别问题

发布于 2025-01-05 16:44:10 字数 335 浏览 0 评论 0原文

我有一个 UIScrollView,在上面我还创建了手势识别器。点击、双击、两根手指点击等。在滚动视图上,我创建了几个其他 UIView。将这些视图中的每一个视为 Drawing 对象。圆形、正方形、按钮、图像等。我可以平移、旋转、点击等每个子视图,并且它们在大多数情况下都可以工作。

如果缩放滚动视图不是 100% (1-1),则平移子视图会变得有点粗略。你总是可以点击它们来让它们突出显示,尽管平移、旋转等是不确定的。通常,如果我尝试平移选定的子视图,它会平移滚动视图。有时有效,有时无效。将缩放设置为 100%,或关闭滚动(将比例设置为相同的最小/最大),我可以执行预期的操作。

关于从哪里开始解决此问题有什么建议吗?

I have a UIScrollView that on it I have also created Gesture Recognizers. Tap, Double Tap, two finger tap, etc. On the Scroll View I create several other UIViews. Think of each of these views as Drawing objects. Circle, Squares, buttons, images, etc. Each of the Subviews I can pan, rotate, tap, etc and they all work for the most part.

If the Scaling Scroll View is not at 100% (1-1) then panning the subviews gets a bit sketchy. you can always tap them to get them to Highlight, though panning, rotation, etc is iffy. Typically if I try to pan a selected subview, it pans the scroll view. Sometimes it works, sometimes it does not. Set the zoom to 100%, or turn off the Scrolling (set scale to the same min/max), I can do what Is expected.

Any Suggestions on where to start troubleshooting this?

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

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

发布评论

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

评论(1

娇纵 2025-01-12 16:44:10

虽然不是 100% 有效,但这是使问题消失的代码。我必须对 UIScrollView 进行子类化,重写 (BOOL)touchesShouldCancelInContentView:(UIView *)view ,如果视图不是 UIScrollView 的 UIView 类,则返回 NO。查看

- (BOOL)touchesShouldCancelInContentView:(UIView *)view { 
    BOOL returnVal =  NO;

    if ([view isKindOfClass:[IoScreenEditorContentView class]]) {
        returnVal = [super touchesShouldCancelInContentView:view];
    }
    return returnVal;
}

Not 100% why this works, but this is the code that made the issue disappear. I had to Subclass UIScrollView, override (BOOL)touchesShouldCancelInContentView:(UIView *)view and return NO if the view was anything but the UIView class for the UIScrollView.View

- (BOOL)touchesShouldCancelInContentView:(UIView *)view { 
    BOOL returnVal =  NO;

    if ([view isKindOfClass:[IoScreenEditorContentView class]]) {
        returnVal = [super touchesShouldCancelInContentView:view];
    }
    return returnVal;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文