Refresh UIPageViewController – reorder pages and add new pages

I found a workaround to force UIPageViewController to forget about cached view controllers of neighboring pages that are currently not displayed: pageViewController.dataSource = nil; pageViewController.dataSource = self; I do this everytime I change the set of pages. Of course this doesn’t affect the currently displayed page. With this workaround I avoid the caching bug and … Read more

Accessing variables from another ViewController in Swift

Everything by default in swift is public, and thus if you declare something like this: class SomeViewController: UIViewController { var someVariable: SomeType = someValue init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) { super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil) } } You can access it as long as you have an instance of it: var myCustomViewController: SomeViewController = SomeViewController(nibName: … Read more

Increase the size of the indicator in UIPageViewController’s UIPageControl

Scaling the page control will scale the dots, but will also scale the spacing in between them. pageControl.transform = CGAffineTransform(scaleX: 2, y: 2) If you want to keep the same spacing between dots, you’ll need to transform the dots individually: pageControl.subviews.forEach { $0.transform = CGAffineTransform(scaleX: 2, y: 2) } However, if you do this in … Read more

How to put the UIPageControl element on top of the sliding pages within a UIPageViewController?

I didn’t have the rep to comment on the answer that originated this, but I really like it. I improved the code and converted it to swift for the below subclass of UIPageViewController: class UIPageViewControllerWithOverlayIndicator: UIPageViewController { override func viewDidLayoutSubviews() { for subView in self.view.subviews as! [UIView] { if subView is UIScrollView { subView.frame = … Read more

UIPageViewController navigates to wrong page with Scroll transition style

My workaround of this bug was to create a block when finished that was setting the same viewcontroller but without animation __weak YourSelfClass *blocksafeSelf = self; [self.pageViewController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:YES completion:^(BOOL finished){ if(finished) { dispatch_async(dispatch_get_main_queue(), ^{ [blocksafeSelf.pageViewController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:NULL];// bug fix for uipageview controller }); } }];

How to implement UIPageViewController that utilizes multiple ViewControllers

First of all, you are absolutely right that the view controllers that constitute the “pages” of the UIPageViewController can be completely different in nature. Nothing whatever says that they have to be instances of the same view controller class. Now let’s get to the actual problem, which is that you very sensibly need a way … Read more