Akash Popat
Akash Popat

Reputation: 420

How to create swiping pages in iOS? Like using FragmentStatePagerAdapter in Android

I've searched quite a lot and most people seem to be recommending either UICollectionView or UIPageViewController but both have drawbacks.

CollectionViews aren't a good implementation because each page will be really involved and will contain a vertical collectionview in it.

PageViewController I'm not sure about because most examples show initializing a view controller and putting it in an array, and Im not sure how I would implement the same type of view controller over and over again with different data and if it would be efficient for dynamic data in the range of 100s of items.

Upvotes: 0

Views: 621

Answers (2)

alegelos
alegelos

Reputation: 2604

A: Page view controller - feed with ViewControllers (better for views with some logic or functionality)

B: CollectionView - feed with prototype cells (better for many not full screen items, with not simple logic like a tap)

C: ScrollView - feed with a view (better for simple full screen views). Remember to enable the "Paging enable"

Upvotes: 0

Duncan C
Duncan C

Reputation: 131426

Yes, both a collection view and a page view controller set to side scroll mode would work well. Both manage large data models, where you only load the few that you need right now into memory.

The page view controller does not use an array of all of your child view controllers. Instead, you give it an array of the current view controller(s) and new view controllers that could be scrolled into view on the left or on the right (The specific details vary depending on how you set up your page view controller. You can set it up to show 2 pages at a time with a center spine like a book, but it doesn't sound like that's what you want.)

Upvotes: 1

Related Questions