我有:
我在界面生成器中收到警告具有不明确的可滚动内容宽度".
据我所知,解决此问题的唯一方法是设置尾随和前导约束.但对于不同的 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 尺寸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
UIScrollView 底部的 UIButtons 不起作用UIButtons at the bottom of UIScrollView not working(UIScrollView 底部的 UIButtons 不起作用)
scrollViewWillEndDragging:withVelocity:targetContentOffset: 不scrollViewWillEndDragging:withVelocity:targetContentOffset: not working on the edges of a UISCrollView(scrollViewWillEndDragging:withVelocity:targetCon
向下滚动时 ImageView 缩放ImageView Scaling when scrolling down(向下滚动时 ImageView 缩放)
UIScrollView 上的边界自动更改,带有内容插图Bounds automatically changes on UIScrollView with content insets(UIScrollView 上的边界自动更改,带有内容插图)
用于 UIScrollView 的 iOS5 UITapRecognizer 干扰按钮.怎么iOS5 UITapRecognizer for UIScrollView interfering with buttons. How to fix?(用于 UIScrollView 的 iOS5 UITapRecognizer 干扰按钮.怎么修?)
使用(自定义、交互式)视图控制器呈现和解除处理Handling scroll views with (custom, interactive) view controller presentation and dismissal(使用(自定义、交互式)视图控制器呈现和解除处