简体   繁体   中英

How to use Freeform Simulated Size to change height of scrollView but not width

I am using the Freeform simulated size to change the View Controller height so I can arrange all subviews in a scrollview .

  • I set the height to 1200
  • Add a scroll view; set the constraints to the superview
  • Then add a UIView called bodyView to the ScrollView to be the container of the body content and set all margins to the scroll view.
  • Add another UIView to be the header with a fixed height of 400 but set the rest of the margins to the BodyView to stay at the top and to be the same width.

    • Add a UIImagevView to the headerView and set all constraints to the header

This is how it looks so far:

在此处输入图片说明

However once the UIViewController is run on smaller device sizes the scroll view retains the original width of 414 and the content does not fit in the frame; even though there is no width constraint set for neither of the sub views.

Does anybody know where I am going wrong and what might be happening ?

I have been researching and even checked out other projects and cannot seem to replicate/resolve the issue.

bodyView必须从外部scrollview获得其宽度,因此,将Control从bodyView拖动到viewController的视图并选择Equal- Widths-高度是根据从上到下的钩子元素计算的

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