ScrollView 中的选取器不滚动

发布于 2024-10-01 00:40:11 字数 333 浏览 1 评论 0原文

我有一个 UIScrollView,里面有一个包含 UIPickerView 的小 UIView。 我可以上下滚动视图,但每当我尝试滚动选择器时,它都会滚动视图。我可以通过单击但不滚动来更改选择器的值。

有什么想法吗?

编辑:我刚刚尝试了 scrollView.canCancelContentTouches = NO; 但它仅在我第一次触摸然后拖动时才有效,如在 TouchesBegan 事件中。如果我像 TouchesMoved 事件中那样触摸移动选取器,scrollView 仍然会滚动。

我该怎么做才能让我的 Picker 在 ScrollView 中具有自然的行为?

I have a UIScrollView, inside it, a small UIView containing a UIPickerView.
I'm able to scroll the view up and down but whenever I try to scroll the picker, it scrolls the view instead. I can change the picker's value by clicking it but not scrolling.

Any ideas?

EDIT: I just tried scrollView.canCancelContentTouches = NO; but it only works when I first Touch and then Drag, as in the TouchesBegan event. The scrollView still scrolls if I touch-move the Picker as in the TouchesMoved event.

What can I do to give my Picker its natural behavior in a ScrollView?

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

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

发布评论

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

评论(1

微暖i 2024-10-08 00:40:11

您已经有了 canCancelContentTouches 设置为 NO,但尝试设置 delaysContentTouchesNO 也是如此。

You've already got canCancelContentTouches set to NO, but try setting delaysContentTouches to NO as well.

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