简体   繁体   English

如何使用Freeform Simulated Size更改scrollView的高度但不更改width

[英]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 . 我正在使用Freeform模拟的大小来更改View Controller高度,以便可以在scrollview安排所有子视图。

  • I set the height to 1200 我将高度设置为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. 然后将一个名为bodyViewUIView添加到ScrollView中,作为主体内容的容器,并将所有边距设置为滚动视图。
  • 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. 添加另一个UIView作为具有固定高度400的标头,但将其余的页边距设置为BodyView以保留在顶部并保持相同的宽度。

    • Add a UIImagevView to the headerView and set all constraints to the header UIImagevView添加到headerView并将所有约束设置为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; 但是,一旦UIViewController在较小的设备尺寸上运行,滚动视图将保留原始宽度414,并且内容不适合框架。 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-高度是根据从上到下的钩子元素计算的

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在Xcode中使用自由格式的模拟尺寸时,如何使屏幕适应? - How to make the screen adapt when you use a freeform simulated size in Xcode? 如何修复“Freeform Size模拟指标在Xcode 4.2之前不可用”警告? - How can I fix “Freeform Size simulated metrics are not available prior to Xcode 4.2” warnings? Xcode模拟大小度量 - Freeform和None设置之间的差异 - Xcode simulated size metric - difference between Freeform and None setting 在 XCode 11 中使用 FreeForm 作为模拟尺寸时,无法将 UIView 安装到 UIViewController 的全尺寸 - Not able to fit UIView to the full size of UIViewController when using FreeForm as Simulated Size in XCode 11 如何在iPad中更改scrollView的大小 - how to change size of scrollView in iPad SwiftUI - 如何获取 ScrollView 内容的大小(高度) - SwiftUI - How to get size (height) of ScrollView content 自由形式子视图的宽度不会扩展到设备屏幕尺寸 - Freeform subview’s width doesn’t expand to device screen size 如何使用内容大小大于scrollView宽度的启用页面的UIScrollView - How to use Page enabled UIScrollView with contente size greater than scrollView width 如何将滚动视图与动态高度的子视图一起使用? - How to use scrollview with subviews of a dynamic height? [iOS]我可以在代码上更改自由格式UIViewController的大小吗? - [iOS]Can I change the size of a freeform UIViewController on code?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM