Andrew
Andrew

Reputation: 3999

How can I scroll through multiple views?

I have multiple views as subclasses of a UIScrollView. I would like to be able to horizontally scroll through those views using page control. What is the best way to do that?

Thanks!

Upvotes: 1

Views: 548

Answers (1)

Dancreek
Dancreek

Reputation: 9544

You don't need for your views to be subclasses of UIScrollView. UIScrollView is a container that allows scrolling of its contents.

Add all your views as subviews to a single UIScrollView. Adjust the contentSize property of the scroll view to be large enough to hold all of your views. Then just add the scrollview to your main view. Take a look at the documentation of the UIScrollView and make sure that you have all of the features enabled that you want. (such as scrolling).

Upvotes: 1

Related Questions