LanePcole
LanePcole

Reputation: 9

swiping between images within the same view controller

I'm new to swift but have android experience. Is there a iOS control similar to the android viewpager? I'm creating an app that has a view controller that contains a large image view and several text fields. The image view covers half the screen or more and the text fields take up the rest of the screen. I need to swipe between images while the text stays in place. What's the best way to implement this? I thought of adding swipe gesture recognizer and changing the image on swipe but is that the best way?

Upvotes: 0

Views: 1059

Answers (2)

R.DelaCruz
R.DelaCruz

Reputation: 11

You can use a Pageview controller, if you're using a storyboard.

  1. Drag a pageviewcontroller into your storyboard
  2. On your main view controller, drag a container view and CTRL + DRAG from your container view towards your pageviewcontroller and choose Embed
  3. Now on your pageviewController define your controllers, for each image make one viewcontroller. So for example if you have 3 images, make 3 viewcontrollers for each. this is the simplest you can do.
  4. Other option would be using CollectionView

Upvotes: 0

Rocker
Rocker

Reputation: 1269

You can use UIPageControl. It has capability to swipe between pages(ie page with image and text)

Upvotes: 1

Related Questions