Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Equivalent to the Android's ViewPager on iOS? Swipe/flip through pages of data

On Android there's neat way to browse between several pages of data with the same layout by using ViewPager and Fragments. User swipes left or right, and the pages change. There's only one view controller and one layout resource for all pages, but the data content changes when the user browses. There's also an animation effect to the swiping left and right where you can see the content of the next page is already loaded.

What is the equivalent to this on iOS?

like image 520
Vanja Avatar asked Mar 16 '12 09:03

Vanja


People also ask

What is difference between ViewPager and ViewPager2?

ViewPager2 is an improved version of the ViewPager library that offers enhanced functionality and addresses common difficulties with using ViewPager . If your app already uses ViewPager , read this page to learn more about migrating to ViewPager2 .

How do I stop ViewPager swiping?

To enable / disable the swiping, just overide two methods: onTouchEvent and onInterceptTouchEvent . Both will return "false" if the paging was disabled. You just need to call the setPagingEnabled method with false and users won't be able to swipe to paginate.

What is Androidx ViewPager widget ViewPager?

Layout manager that allows the user to flip left and right through pages of data. You supply an implementation of a PagerAdapter to generate the pages that the view shows. ViewPager is most often used in conjunction with android. app.


3 Answers

Use a UIScrollView with the pagingEnabled property set to YES. Typically a UIPageControl is used along with it.

If you Google for "UIScrollView paging", you can find many tutorials and examples. Apple provides a PageControl sample program.

iOS doesn't provide any sort of adapter-like class, but here is a tutorial that explains how to implement "virtual pages" so that you don't have to instantiate all the pages at once: http://cocoawithlove.com/2009/01/multiple-virtual-pages-in-uiscrollview.html

like image 155
Kristopher Johnson Avatar answered Oct 04 '22 10:10

Kristopher Johnson


You should look at UIPageViewController. Its available since iOS 5.

like image 44
Ingolmo Avatar answered Oct 04 '22 08:10

Ingolmo


I've created a custom control for iOS which acts similar to android's viewPager. You can check this out here.

like image 29
Shabib Avatar answered Oct 04 '22 10:10

Shabib