使用 UIScrollView 时第二个 UIScrollView 响应
这更多的是一种检查,因为我相信这是正确的,但如果我错了,那就需要做很多工作。
我想基本上用滚动视图实现固定定位。我希望顶部有一个始终可见的列表,仅水平滚动,然后在其下方有一个滚动视图,以围绕垂直和水平滚动的信息移动。
我想我需要子类化 UIScrollView 并覆盖touchesBegan、touchesMoved 和touchesEnded 将触摸发送到两个UIScrollView。
这是正确的还是偏离轨道的?
干杯
This is more of a check as I believe this is right but its a lot of work if I'm wrong.
I want to basically achieve fixed positioning with a scrollView. I want to have a list along the top that is always visible, scrolls horizontal only and then a scrollview beneath that to move around the information which scrolls both vertically and horizontally.
I figure I need to subclass UIScrollView and overwrite touchesBegan, touchesMoved and touchesEnded to send the touch to both UIScrollViews.
Is this right or off track?
Cheers
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
覆盖滚动视图上的触摸事件可能不是您想要做的。相反,您可以简单地使用单个滚动视图,然后在父视图的 -layoutSubviews 或滚动视图的委托方法中,您可以移动列表,使其始终处于相同的垂直位置(使用滚动视图的
contentOffset
属性来确定它应该在哪里)。委托方法和 -layoutSubviews 都会在滚动视图滚动后实际发生绘制之前调用,因此通过始终将视图重新定位到您想要的位置,它对于用户来说似乎保持固定。Overriding the touch events on a scroll view is probably not what you want to do. Instead you can simply use a single scroll view, and then in the parent view's -layoutSubviews or in the scroll view's delegate methods you can move the list so it's always at the same vertical position (use the scroll view's
contentOffset
property to determine where that should be). Both the delegate method and -layoutSubviews is called before the drawing actually occurs after the scroll view scrolls, so by always repositioning your view where you want it to be, it will appear to remain fixed to the user.