水平分页,每页垂直滚动!
在我的应用程序中,我使用页面控件和 UIScrollView 来水平分页,我希望能够在每个页面上启用垂直滚动。现在我知道你可以嵌套 UIScrollViews 来实现这一目标,但是我的项目中存在一个问题。每个页面都使用一个视图控制器,该控制器由一个视图和一个背景图像(每个页面都有不同的图像)组成。该背景图像在上下滚动时不应移动。
现在我想要的是能够拥有按钮,常规的矩形按钮,我在 Interface Builder 中创建它们(因为我希望能够轻松地设计和更新位置),然后可以垂直滚动。
所以它应该是这样的:
您会看到一个屏幕,底部有一个页面控件,上面有一个带有按钮的图像。当您向侧面滚动时,您会转到另一个页面,同样带有图像(另一个)和不同的按钮。现在,每当您在页面上垂直滚动时,按钮都应该是可滚动的(因此我可以在一页上有很多按钮),但图像应该保持其位置。
所以我想,我只需在带有背景图像的视图顶部添加另一个滚动视图即可。这工作正常,因为我现在将按钮悬停在背景图像上,并且每个页面(包括按钮)都有一个单独的 nib 文件。但是当我这样做时,带有按钮的滚动视图变得不可垂直滚动。我不知道为什么会发生这种情况,所以有人可以建议我如何实现想要的结果吗?
我真的会非常非常感激!
谢谢,
法比安
In my app I use a page control and a UIScrollView to page horizontally, I'd like to be able to enable vertical scrolling on each page. Now I know you can nest UIScrollViews in order to achieve this, there is however one problem in my project. Each of the pages uses a view controller consisting of a view, with a background image (different image for each page). This background image should not move while scrolling up and down.
Now what I want is the ability to have buttons, regular rect buttons, which I create in Interface Builder (since I want to be able to design and update the positions easily) and which then can be scrolled vertically.
So it should be like this:
You see a screen with a page-control on the bottom, above it an image with buttons over it. When you scroll sideways, you go to another page, again with an image (another one) and with different buttons. Now whenever you scroll vertically on a page, the buttons should be scrollable (so I can have a LOT of buttons on 1 page), but the image should maintain it's position.
So I figured, I just add another scroll view on top of the view with the background image. This works fine since I now have my buttons hovering over the background image and I have a separate nib file for each page including the buttons. But when I do it like this, the scrollview with the buttons becomes un-scrollable vertically. I don't know why this is happening, so could anyone suggest me how to achieve the wanted result?
I'd be really really grateful!
Thanks,
Fabian
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论