将滑动事件提供给其他控件

发布于 2024-07-21 07:13:45 字数 242 浏览 4 评论 0原文

我在 UIView 之上有一个 UITextView。 它们位于 PageScrollView 中。 用户可以在 UITextView 之外的任意位置滑动并轻拂下一页(视图)。 我希望用户在 UITextView 上滑动并轻拂下一个视图。

当文本太多时,UITextView 会垂直滚动,用户可以滑动文本并查看其余文本。 查看水平分页滚动。 我需要 UITextView 将其水平滑动给 UIView。 我怎样才能做到这一点?

I have a UITextView on top of a UIView. They are in a PageScrollView. The user can swipe anyhere outside of the UITextView and flick over the next page (view). I'd like the user to swipe on the UITextView and flick over the next view as well.

The UITextView scrolls vertically when there is to much text, which the user can swipe and see the rest. View paging scrolls horizontally. I need the UITextView to give its horizontal swipe to the UIView. How can I do that?

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

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

发布评论

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

评论(1

月寒剑心 2024-07-28 07:13:45

如果您子类化 UITextView 并覆盖它的每个触摸事件:

  • touchesBegan:withEvent:
  • touchesMoved:withEvent:
  • touchesEnded:withEvent:
  • touchesCancelled:withEvent:

with this:

- (void) touchesXXX:(NSSet *)touches withEvent:(UIEvent *)event {
    [super touchesXXX:touches withEvent:event];
    [[self nextResponder] touchesXXX:touches withEvent:event];
}

这将允许通过 处理所有触摸>UITextView 及其父视图。 由于您的 UITextView 仅垂直滚动,而 UIScrollView 仅水平滚动,因此效果很好。

If you subclass UITextView and override each of it's touch events:

  • touchesBegan:withEvent:
  • touchesMoved:withEvent:
  • touchesEnded:withEvent:
  • touchesCancelled:withEvent:

with this:

- (void) touchesXXX:(NSSet *)touches withEvent:(UIEvent *)event {
    [super touchesXXX:touches withEvent:event];
    [[self nextResponder] touchesXXX:touches withEvent:event];
}

This will allow handling of all touches by both the UITextView and its parent view. Since your UITextView scrolls exclusively vertically and your UIScrollView scrolls exclusively horizontally, this will work out fine.

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