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?
Asked
Active
Viewed 1,016 times
0
-
The best way is to use UIScrollView with paging enabled. – Retterdesdialogs Jan 23 '18 at 17:21
-
1You can use UIScrollView and UIPageControl for that. Check [this SO post](https://stackoverflow.com/questions/29074454/how-to-create-a-scroll-view-with-a-page-control-using-swift) out. – Phyber Jan 23 '18 at 17:27
-
1https://www.raywenderlich.com/159481/uiscrollview-tutorial-getting-started – MAhipal Singh Jan 23 '18 at 17:27
-
1"Is there a iOS control similar to the android viewpager?" UIPageViewController maybe??? – matt Jan 23 '18 at 17:28
2 Answers
1
You can use UIPageControl. It has capability to swipe between pages(ie page with image and text)

Rocker
- 1,269
- 7
- 15
-
1It 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.
- Drag a pageviewcontroller into your storyboard
- On your main view controller, drag a container view and CTRL + DRAG from your container view towards your pageviewcontroller and choose Embed
- 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.
- Other option would be using CollectionView

R.DelaCruz
- 11
- 3