简体   繁体   中英

How to horizontally scroll between pages of controls in UIScrollView iOS/Swift

I am trying to find the way to implement a scroll view on my viewController screen, which allows the user to scroll between different pages of controls and have the controls around it, outside the scroll view, react to whatever data or actions take place in the scroll view.

All the tutorials I have found is adding a scroll view that shows a carousel of images, or programmatically adding coloured frames. Very little control interaction.

But none that shows how to create 2-3 pages of controls (buttons and labels), and how to integrate it with the parent view (so the parent view and scroll view talk to each other in one view).

So for now, what would be the first step to create a scroll view with 2 'pages' of controls? Has anyone come across any good resources for this? How is the best way to achieve this?

Thanks!

  1. Add Scroll View. Add top,left,right, bottom constraint to scroll view. Set horizontal only in storyboard.
  2. Add a view inside scroll view. Now add height constraint from this view to super view. (Not the scroll view.) Specify some width and add width constraint. I suggest you to use UIPageViewController for this type of scrolling.

I suggest you go for UICollectionViewLayout and enable paging to true. Using this will give you the finest control of each page and the horizontal as well as vertical scroll.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM