Search code examples
iosuipageviewcontrolleruipagecontrol

iOS paged view controller


I would like to implement a paged view controller,

is it possible for this to be done through storyboard?

i would like to page between 4 views,

The first 2 views will have same layout (image view at top and text view at bottom)

the 3rd view will contain many labels

the 4th just contain a video.

is it possible to design 5 view controllers in storyboard and to link them into one view controller to be paged?

Thanks


Solution

  • This doesn't specifically answer how to do it with a Paged View Controller, but I think this would be much easier to do using a UIScrollView with paging enabled. Then you only have to customize code for a single view controller instead of five of them.

    In your storyboard, you can use autolayout, and make your view freeform so you can stretch it out horizontally to show all four of your inner views to set up your constrained layout.

    So create a scrollview that's constrained to the width of the top level view. Then stretch the top level view way out and put in four UIViews that are constrained to touch each other and fill the scroll view (from the left end of the scroll view to the right, make size zero trailing/leading space constraints) and constrained to equal the width of the top level view.