英文:
UIScrollView with UIStackView which resizes to fullfill the screen height
问题
没有代码,因为一切都放在xib中。
结构:UIScrollView
包含 UIView
(https://stackoverflow.com/questions/19036228/uiscrollview-scrollable-content-size-ambiguity)其中包含 UIStackView
,其中包含一系列子视图。所有 UIStackView
子视图的高度都是固定的,除了一个只有 "最小高度" 的视图,我需要拉伸此视图以使 UIStackView
在必要时填满所有可用高度。如果 UIStackView
很大,那么 UIScrollView
应该滚动 UIStackView
。
尝试了很多组合,但唯一应该拉伸或折叠的视图具有不可预测的高度。在较好的情况下,它能够按预期工作,但 UIScrollView
的内容完全忽略了安全区域(变得比预期大)。
有人遇到过这个问题吗?
已编辑
这是xib中的视图控制器,通过加载/模态呈现。
链接到xib
英文:
No code because everything is placed in xib.
Structure: UIScrollView
contains UIView
(https://stackoverflow.com/questions/19036228/uiscrollview-scrollable-content-size-ambiguity) which contains UIStackView
which contains a list of subviews. All the UIStackView
subviews have fixed height except of one which has "minimal height" only and I need to stretch this view to make UIStackView
fullfilling all available height if necessary. If UIStackView
is very big then UIScrollView
should scroll UIStackView
.
Tried a lot of combinations but the only view which should stretch or collapse has unpredictable height. In better case it works as expected but UIScrollView
content fully ignores safe area (becomes larger than expected).
Did somebody faced this problem?
Edited
It is a view controller inside xib, loading/presenting modally.
A link to xib
答案1
得分: 0
发现了一个奇怪的解决方案:
- 禁用根视图的安全区域
- 启用滚动视图的安全区域(直接插入到根视图中)
- 设置像这里(leading,trailing,top,bottom,equal width,equal height with low priority)的约束,唯一的区别是滚动视图的根视图高度应该等于安全区域高度而不是父视图的高度
也许有人可以提供更好的解决方案。
英文:
Found a weird solution:
- disable safe area for the root view
- enable safe area for scroll view (which is is inserted directly in the root view)
- setup constraints like here (leading, trailing, top, bottom, equal width, equal height with low priority) with one difference - scroll view's root view height should be equal not to superview height but to safe area height
But maybe someone can suggest a better solution
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论