0

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?

Dávid Pásztor
  • 51,403
  • 9
  • 85
  • 116
LanePcole
  • 9
  • 6

2 Answers2

1

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

Rocker
  • 1,269
  • 7
  • 15
  • 1
    It would be more helpful if you also post examples in addition to identifying the recommended class. – Mark A. Donohoe Jan 23 '18 at 18:01
  • I ended up adding a UIScrollView and a UIPageControl to the View Controller. Worked Great! Thanks to @Phyber for the comment above. – LanePcole Jan 23 '18 at 20:41
0

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
R.DelaCruz
  • 11
  • 3