即使按下按钮子视图,如何使滚动视图滚动

发布于 2025-01-07 04:33:26 字数 261 浏览 3 评论 0原文

关于 UIScrollView、触摸事件和子视图有无数的问题,但我找不到一个可以解决我的困境的问题。我有一个带有延迟和可取消内容触摸的 UIScrollView,我在其中添加了 UIButton。我可以在触摸的任何地方(包括按钮)滚动视图,但如果我的手指在按钮上停留太久,它就会记录为触摸该按钮,正如我想要的和预期的那样。但是,如果我像尝试滚动一样移动手指,则滚动视图不会滚动 - 我怎样才能让它这样做?我想要实现的基本效果就像 UITableView 处理单元格的触摸一样。

感谢您的帮助。

There are countless questions about UIScrollViews, touch events and subviews, but I couldn't find one that solved my dilemma. I have a UIScrollView with delayed and cancellable content touches in which I have added UIButtons. I can scroll the view wherever I touch (including the buttons), but if my finger lingers on a button for too long, it registers as touching the button, as I want and is expected. However, if I then move my finger as if trying to scroll, the scroll view does not scroll - how can I make it do so? The basic effect I am trying to achieve is like a UITableView handles touches for the cells.

Thanks for your help.

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

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

发布评论

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

评论(1

濫情▎り 2025-01-14 04:33:26

尝试在 UIScrollView 子类中实现以下内容:

- (BOOL)touchesShouldCancelInContentView:(UIView *)view {   
    return YES;
}

Try implementing the following in your UIScrollView subclass:

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