的UIScrollView +中心的观点+ Ambigous滚动的内容大小+许多iPhone尺寸 [英] UIScrollView + Centered View + Ambigous Scrollable Content Size + many iPhone sizes

查看:330
本文介绍了的UIScrollView +中心的观点+ Ambigous滚动的内容大小+许多iPhone尺寸的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有:


  • 申请,应在横向和纵向模式。

  • 观点与顶级全尺寸滚动视图。

  • 以固定宽度和高度滚动视图里面的一些观点。 (添加了H和W的限制)

  • 设置,查看滚动视图水平在容器内居中。 (据加约束)

我在Interface Builder已经警告有暧昧滚动内容的宽度。

I have warning in interface builder "Has ambiguous scrollable content width".

只有这样,才能解决这个问题,我知道 - 设置尾随和领先的制约。
但对于不同的iPhone(5.5,4.7,4),我需要设置不同的拖尾和领先的制约。

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.

我怎么可以消除这个警告,仍然都集中水平查看与固定W和H为所有iPhone尺寸?

How can I eliminate this warning and still have centered horizontally view with fixed W and H for all iPhone sizes?

我创建Github上回购来说明这个问题: ScrollViewAmbigous

I create Github repo to illustrate this problem: ScrollViewAmbigous

这是不重复的<一个href=\"http://stackoverflow.com/questions/19036228/uiscrollview-scrollable-content-size-ambiguity-x$c$c-5-ios-7-interface-builder\">UIScrollView滚动内容大小歧义(X code 5的iOS 7界面生成器)
的,但它类似(并且没有回答尽管),但这个问题特别是与不同尺寸的iPhone。

推荐答案

在早上的一杯新鲜咖啡我想出的办法解决这个问题!

In the morning with a fresh cup of coffee I figured out workaround for this issue!


  1. 滚动视图以0约束,所有的边缘

  2. 按钮居中水平和垂直固定宽度和高度

  3. ,当然有暧昧滚动内容宽度的暧昧滚动内容高度 恼人的警告

  1. scrollView with 0 constraints to all edges
  2. Button centered Horizontal and Vertical with fixed Width and Height
  3. And, of course Has ambiguous scrollable content width and Has ambiguous scrollable content height annoying warnings.


  • 添加2个额外的约束,例如0拖尾和/或底部空间,我们认为(在我的情况 - 的UIButton)

重要:您必须添加尾随和/或底部的约束。不是领导和顶! - 这不是作品

Important: you have to add trailing and/or bottom constraints. Not "leading and top" - it's not works!

您可以在我的示例项目检查它,演示如何解决此问题: ScrollViewAmbigous

You can check it in my example project, that demonstrating how to fix this issue: ScrollViewAmbigous

P.S。

我不知道为什么它的工作原理和X code如何检测哪些约束更优先(因为我不是为这些约束条件明确地设置优先级),但我会感激如果有人解释,为什么它工作在下面的评论。

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 +中心的观点+ Ambigous滚动的内容大小+许多iPhone尺寸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆