我有:
我在界面生成器中收到警告具有不明确的可滚动内容宽度".
据我所知,解决此问题的唯一方法是设置尾随和前导约束.但对于不同的 iPhone(5.5"、4.7"、4"),我需要设置不同的尾随和前导约束.
我怎样才能消除这个警告,并且仍然在所有 iPhone 尺寸的固定 W 和 H 的情况下保持居中的水平视图?
我创建 Github repo 来说明这个问题:
附言
我不知道它为什么起作用以及 Xcode 如何检测哪个约束的优先级更高(因为我没有明确为这些约束设置优先级),但如果有人解释,我将不胜感激,为什么它在下面的评论中起作用.
I have:
I have warning in interface builder "Has ambiguous scrollable content width".
The only way to fix this problem, that I know - is set trailing and leading constraints. But for different iPhones (5.5", 4.7", 4") I need to set different trailing and leading constraints.
How can I eliminate this warning and still have centered horizontally view with fixed W and H for all iPhone sizes?
I create Github repo to illustrate this problem: ScrollViewAmbigous
This is not duplicate of UIScrollView Scrollable Content Size Ambiguity , but it similar (and not answered although), but this question especially related to different sizes of iPhones.
In the morning with a fresh cup of coffee I figured out workaround for this issue!
Has ambiguous scrollable content width
and Has ambiguous scrollable content height
annoying warnings.Important: you have to add trailing and/or bottom constraints. Not "leading and top" - it's not works!
You can check it in my example project, that demonstrating how to fix this issue: ScrollViewAmbigous
P.S.
I don't know why it works and how Xcode detect which constraint is more prioritised (because I'm not set priority for these constraints explicity), but I'll be thankful if someone explain, why it works in comments below.
这篇关于UIScrollView + 居中视图 + 模糊的可滚动内容大小 + 许多 iPhone 尺寸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!