带有 UIPageControl 的 UIView
在页面控制方面我是一个初学者,这就是为什么我不能100%确定我的标题是否符合我想要的。我想制作一个 UIPageControl,当用户在屏幕上滑动时,视图会切换到另一个视图,并且屏幕底部的 UIPageController 会自行更新。另外,为了使我的请求更加混乱,我希望屏幕底部有一个选项卡栏,该选项卡栏会随着视图的变化而保持不变。
The Iconfactory 的 Ramp Champ 就是一个很好的例子: http://img.slidetoplay.com/screenshots/ramp-champ_5.jpg
底部的栏当屏幕上的其余项目移动时保持不动。做到这一点最简单的方法是什么?
编辑:我知道我必须使用 UISrollView,我只是不知道如何去实现它......
I'm a beginner when it comes to page control, and that's why I'm not sure 100% if my title agrees with what I want. I want to make a UIPageControl that when the user swipes on the screen, the view would switch over to another view and the UIPageController at the bottom of the screen would update itself. Also, to make my request even more confusing, I want a tab bar at the bottom of the screen that would stay put as the views change.
A great example of this is The Iconfactory's Ramp Champ:
http://img.slidetoplay.com/screenshots/ramp-champ_5.jpg
The bar at the bottom stays put while the rest of the items on the screen moves. What would be the easiest way to do this?
EDIT: I know I have to use a UISrollView, I just don't know how to go about implementing it...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要使用 UIScrollView
假设你有一个名为scrollView的命名ivar
然后你需要实现所需的委托方法,以便你可以更新你的页面控件
你需要将你想要滚动的任何内容放在这些scrollview中,最好是延迟加载到其中,如果内容您将显示需要大量堆内存,请使用scrollviewDidScroll在所需位置删除和添加内容
You need to use a UIScrollView
Assuming you have a named ivar called scrollView
You will then need to implement the required delegate methods, so that you can update your page control
You need to place whatever content you want to be scrollable inside these scrollview, ideally lazyload into it, if the content you will displaying will require a lot of heap memory, use the scrollviewDidScroll to remove and add content at the required positions
我相信您正在寻找的实际上是 UIScrollView 将 pagingEnabled 设置为 YES。您可以将滚动视图保留为常规 UITabBar 上方的视图。您将使用 UIPageControl 来获取小点。当 UIScrollView 滚动到页面时,您可以通过实现滚动视图的适当委托方法(可能是 -scrollViewDidScroll:)以编程方式更新它。
假设您有两个 ivars:scrollView 和 pageControl。当您知道滚动视图将有多少页时,您可以设置滚动视图的 contentSize。它应该是滚动视图边界的倍数。例如,如果页数是静态的,您可以在 -viewDidLoad 中对其进行硬编码...
然后,更新您的小点...
I believe what you're looking for is actually a UIScrollView with pagingEnabled set to YES. You can leave the scrollview as a view above a regular UITabBar. You'll use a UIPageControl to get the little dots. You can update it programmatically when the UIScrollView scrolls to a page by implementing an appropriate delegate method of the scroll view, maybe -scrollViewDidScroll:.
Assume you have two ivars: scrollView and pageControl. When you know how many pages your scroll view will have, you can set the contentSize of scrollView. It should be a multiple of the scrollView's bounds. For example, if the number of pages is static you can hardcode it in your -viewDidLoad...
Then, to update your little dots...