iOSDev
iOSDev

Reputation: 3617

Correct way to handle swipes between UIViews

I have two views that I want to show using paging control on home screen of my app. If user swipes on UI, it should show second view which is UITableView. First view is also UITableview.

I want to know the correct way of handling this swipes and add two round images that indicate selected page. Whether I should go for scroll view paging or use gesture recogniser.

What is better way of doing this?

Upvotes: 0

Views: 1765

Answers (2)

Jean-Francois Gagnon
Jean-Francois Gagnon

Reputation: 3290

If I understand correctly, you should use a UIPageViewController.

Class Reference

Edit

If you want to add some sort of UIPageControl to your UIPageViewController, you need to use these 2 methods (from UIPageViewControllerDataSource):

- (NSInteger)presentationCountForPageViewController:(UIPageViewController *)pageViewController
- (NSInteger)presentationIndexForPageViewController:(UIPageViewController *)pageViewController

Here's a complete tutorial on using UIPageViewController (with a page control, like you want). http://mobile.tutsplus.com/tutorials/iphone/using-scrollstyle-with-uipageviewcontroller/

Upvotes: 3

Zhang
Zhang

Reputation: 11607

I would put the two UITableViews into a UIScrollView with pagination.

UIScrollView already handles the swipe for you and also it has the bounce animation from the pagination.

If you were to manually handle swipe gesture, you'll likely have to implement your own bounce animation and also swipe interruption in case the user swipes back the other way while the view is being transitioned across.

Upvotes: 1

Related Questions