xcode 带有 PageControl 的 UIPageViewController
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15677682/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
UIPageViewController with PageControl
提问by Daniel Kappacher
I'm using a UIPageViewController to display 4 other ViewControllers. So my RootViewController is a PageViewController which displays 4 other ViewControllers I created in my Storyboard with segues to different Views . All works perfect. But is it possible to add an UIPageControl to this PageViewController. Is this possible anyhow?
我正在使用 UIPageViewController 来显示 4 个其他 ViewController。所以我的 RootViewController 是一个 PageViewController,它显示了我在我的 Storyboard 中创建的 4 个其他 ViewControllers 与不同的 Views 。一切都很完美。但是是否可以向这个 PageViewController 添加一个 UIPageControl。这可能吗?
Or has someone an idea how I can achieve a similar result?
或者有人知道我如何获得类似的结果?
Would be great, thanks!
会很棒,谢谢!
回答by yjsoon
You need to implement these UIPageViewControllerDataSource
methods:
您需要实现这些UIPageViewControllerDataSource
方法:
Swift
迅速
func presentationCount(for pageViewController: UIPageViewController) -> Int { ... }
func presentationIndex(for pageViewController: UIPageViewController) -> Int { ... }
Obj-C
对象-C
- (NSInteger)presentationCountForPageViewController:(UIPageViewController *)pageViewController
- (NSInteger)presentationIndexForPageViewController:(UIPageViewController *)pageViewController
And you'll get a page control showing up at the bottom 36px of your UIPageViewController. Try changing the color of the view to a dark color, if you can't see them.
你会在 UIPageViewController 底部 36px 处看到一个页面控件。如果您看不到它们,请尝试将视图的颜色更改为深色。