I am using Xcode 6 and implementing UIPageViewController
for my app. I followed appcoda's tutorial, and everything works except the page indicators. This is because I cannot set the transition style of UIPageViewController
to scroll.
Graphically, when I click on the PageViewController
, the tab shows View Controller instead of Page View Controller like appcoda
(See its image below)
This is what mine looks like:
And yes, my custom class is set to: UIPageViewController
as it is in the tutorial.
Programmatically, I try to set the transition style with:
self.pageViewController.transitionStyle = UIPageViewControllerTransitionStyle.Scroll
but it fails to build, telling me that it Could not find member transition style. One last weird thing I would like to point out is that if I just write self.pageViewController.transitionStyle
, it builds successfully, but it still uses the Page Curl
Transition.
Could anyone help me? I am using Swift, Xcode 6, and developing on the iOS 8 SDK.
You're getting an error because transitionStyle
is a readonly property. If you want to set the transition style of the page controller programmatically, it can only be done during initialization with the method:
init(transitionStyle style: UIPageViewControllerTransitionStyle, navigationOrientation navigationOrientation: UIPageViewControllerNavigationOrientation, options options: [NSObject : AnyObject]!) { ... }
More info in the documentation.
The issue is that when you create a UIPageViewController inside a Container, the container is first created with a UIViewController, and that s the controller you see your options for.
In order to fix it you have to delete UIViewController where you set your custom UIPageViewController. Then drag UIPageViewController from the controls picker and hook up the embed segue from the container to that controller, then you can set your custom pager controller as well as set transition to scroll.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With