Aladin
Aladin

Reputation: 115

How to add another page to an UIScrollView by swiping?

I am a french 17 years old guy so excuse my english.

I am creating an app' using an UIScrollView with an UIPageControl to display multiple UIView pages from UIViewControllers (which display an object) . Everything works pretty great.

Now i would like to add a new page (and a new empty object but that is not a problem) when I swipe the UIScrollView to the right in the last view.

How could I do that ? And if it's not possible, how can I update the UIScrollView ?

Thank you very much !

Upvotes: 0

Views: 1009

Answers (2)

CedricSoubrie
CedricSoubrie

Reputation: 6697

This is what you are looking for I think : a sample code from Apple to build a photo viewer that load images just before they appear on screen.

https://developer.apple.com/library/ios/#samplecode/PhotoScroller/Introduction/Intro.html#//apple_ref/doc/uid/DTS40010080

Upvotes: 0

Akshay
Akshay

Reputation: 5765

I think you need to keep an eye on two things. scrollViewDidScroll: & UIPageControl's currentPage. When you determine that the user is currently viewing the rightmost page & the UIScrollView was scrolled, you can add a new page to the UIPageControl. The amount by which the scroll view was scrolled is related to scrollView.contentOffset.x. A new page can be added to the page control by incrementing its numberOfPages & setting the currentPage to the newest page.

HTH,

Akshay

Upvotes: 1

Related Questions