0

I am creating a paging UIScrollView which contains several pages. On each page is a UIViewController some of which are quite memory intensive and others which will be used multiple times and I hope to reuse.

My first attempt was to create the illusion of many pages by using an infinite paging similar to this answer continuous paging.

I've encountered some difficulty in implementing this though. What is the best approach to load many view controllers in a scrollView without having them all instantiated at the same time.

nathan
  • 9,329
  • 4
  • 37
  • 51
  • What do u mean by this `quite memory intensive` ? Is there API calling for each controller ? – Nizzam Apr 18 '19 at 02:32
  • @Nizzam I would like to have images, collectionViews network calls on different view controllers having them all initialized and being apart of a parent view while not in view could become quite resource intensive. – TheRedCamaro3.0 3.0 Apr 18 '19 at 06:13

1 Answers1

0

Use a UIPageViewController. It implements this for you.

matt
  • 515,959
  • 87
  • 875
  • 1,141
  • Thank you for your answer, I have tried experimenting with UIPageViewController but Ive had trouble when it comes to reusability of view controllers and keeping track of the current page number the user is on, the direction the user scrolled and making custom animations as the user swipes between UIViewControllers can be a bit more complex than when compared to UIScrollView or other container views. – TheRedCamaro3.0 3.0 Apr 18 '19 at 06:15