简体   繁体   中英

Adding a scrollbar to a ViewController (storyboard)

I would like to add a scrollbar type mechanic to an app view. From what I have looked for it at first seemed like a UIScrollView would be the optimal choice but now I am not so sure..

Basically all I want to do is be able to add numerous text boxes, sliders, and buttons etc into a view. The problem is how many I need to add at any one time is determined based on user input so it is entirely possible the amount of objects I need to add to the view may not fit in just one screen. All I need to do is to be able to scroll down further and allow the user to see the other input options.

Is this something the scrollview is used for? If so, how do i drag/drop buttons/text boxes into the scrollview so they appear.. well, below the normal resolution so you must scroll down to see them. When I attempt to drag/drop objects into the view controller I can't go below the normal size of the box.

I hope I explained this clearly enough.

Thanks.

  1. While a generic UIScrollView certainly can be used for what you want, in practice you may find that a UITableView fits better... you see a lot of "forms" are implemented in such a manner and lets you do things like access a field by indexPath.
  2. To accomplish what you are trying to do, follow the instructions in Scrolling through UIScrollView in Interface Builder for Xcode 4 - in short, you will create your embedded view inside the view controller's view, temporarily move it to the top of the view hierarchy for scrolling and control layout purposes, and move it back to the the view controller's view when finished.
  3. You don't put views/controls in a view controller you put them in a view which is managed by a view controller.

Hope that helps.

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