简体   繁体   中英

How to add views in UIScrollview and then add constraints using storyboard iOS objC

I am creating UI like below image. 在此处输入图片说明

I kept one view at bottom and one view at top using storyboard and constraints. Now between these two views there is some are which I want to scroll. I have added some labels , buttons to it and added constraints. Up to this,it works perfect (Only middle portion of screen is only scrolling). But I am having 600 * 600 area(using width any, height any -sizes class) in which top view has fixed height constraint 80 and bottom view having fixed height 100. My problem is , there some more labels and buttons to be added in same scrollview below existing ones. How do I place more views in storyboard iOS objC

You want to use a UITableView with a bunch of UITableViewCell members. It automatically sets up the scroll behavior that you are looking for. Based on the index of the UITableViewCell you can present whatever data that you want to in the cell.

I don't know exact solution,but I have tried something like this. So my answer could help some one else

1: Make a UIView subclass that will contain all the buttons you could ever want.

2: Make a XIB for it, NOT in the Storyboard. Add the buttons to a blank, resizable UIView and link them up.

3: When UIViewController WITH the UIScrollView loads. init the subclassed UIView using initWithNibNamed...

4: Add it as a subView of the UIScrollView and set scrollView.contentSize

在此处输入图片说明

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