Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I subclass UIPageViewController?

What's the preferred way to use UIPageViewController?

  1. Subclass UIPageViewController and also use that object as the datasource for itself?

  2. Create a container VC and add a UIPageViewController as its child VC? (having the container VC be the data source)

Pros/Cons to either approach would be appreciated.

like image 879
Rizon Avatar asked Apr 04 '15 17:04

Rizon


2 Answers

Approach #2 is preferred. If you use #1, you might run into this layout issue. Also, UIPageViewController has many readonly properties, and using composition instead of inheritance will encourage you to use it in the way in which it was designed.

like image 111
Aaron Brager Avatar answered Oct 21 '22 01:10

Aaron Brager


You don't need to create a parent view controller to implement delegation methods.

You can simply drag an NSObject in the scene browser and set it's class to your datasource/delegate object.

enter image description here

like image 24
Moose Avatar answered Oct 21 '22 01:10

Moose