[英]how to give Page View Controller a “Cover Vertical” transition style
With a Navigation View Controller, I can give a "Cover Vertical" transition style animation. 使用Navigation View Controller,我可以给出“垂直覆盖”过渡样式的动画。 However, having trouble replicating that with a Page View Controller.
但是,在使用Page View Controller复制该代码时遇到了麻烦。 The only options given in the story board are "Scroll" and "Page Curl".
故事板上提供的唯一选项是“滚动”和“页面卷曲”。 Is there a way to do this programmatically?
有办法以编程方式执行此操作吗?
It looks a little bit tricky but it should work : 它看起来有些棘手,但应该可以使用:
Create a UIViewController which will be a Container Controller. 创建一个UIViewController,它将是一个容器控制器。 Add a UIPageControl where ever you want.
在需要的地方添加UIPageControl。 Then programmatically add a UINavigationViewController as a child of the container and add its view to the view hierarchy.
然后以编程方式将UINavigationViewController添加为容器的子项,并将其视图添加到视图层次结构中。 You can use instantiateViewControllerWithIdentifier: of the main storyboard and don't forget to set constraints to it if you're using AutoLayout.
您可以使用主情节提要的InstantiateViewControllerWithIdentifier:,并且如果您使用的是AutoLayout,请不要忘记为其设置约束。 Use a delegate between the container and the UINavigationViewController or the parentViewController property of the UINavigationViewController to change UIPageControl when the user navigates in the UINavigationViewController.
当用户在UINavigationViewController中导航时,请在容器与UINavigationViewController或UINavigationViewController的parentViewController属性之间使用委托来更改UIPageControl。
UIPageViewController is good to do only one single thing. UIPageViewController最好只做一件事情。 Most of the time I prefer using a custom container controller rather than using it.
大多数时候,我更喜欢使用自定义容器控制器而不是使用它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.