简体   繁体   English

iPhone5的Xcode限制搞砸了我

[英]Xcode constraints for iPhone5 messing me up

I'm trying to do a thing that seems easy but since the new auto layout in xcode I having a hard time to understand what's going on with the constraints. 我正在尝试做一件看似简单的事情但是由于xcode中的新自动布局我很难理解约束发生了什么。

The thing I want to do is 2 subviews in a main view basically one scrollview at the top and one uiview at the bottom with no space in between 我想要做的是主视图中的2个子视图,基本上是顶部的一个滚动视图和底部的一个uiview,两者之间没有空格

on iPhone 5 I want it to be 在iPhone 5上,我希望它是
400px 400像素
148px 148px

and on iPhone 4 : 在iPhone 4上:
358px 358px
112px 112px

Each time I'm adding a constraint one other disappear or an other one doesn't allows me to change the height 每次我添加一个约束时,另一个消失或另一个不允许我改变高度
I don't know if this is explainable or what but any help is welcome 我不知道这是否可以解释,或者欢迎任何帮助

I hate the new AutoLayout in Interface Builder. 我讨厌Interface Builder中的新AutoLayout The first thing I do is disable it. 我做的第一件事是禁用它。 Just disable it by clicking on File's Owner > Show File Inspector , then untick Use AutoLayout . 只需通过单击文件的所有者 > 显示文件检查器 ,然后取消选中使用自动布局来禁用它。

The problem I found about Auto Resizing and Size Classes is that the purpose of them is to handle complex UI layouts, so: 我发现有关自动调整大小和大小类的问题是它们的目的是处理复杂的UI布局,因此:

  1. If the UI you're building is as simple as the apps that shipped by Apple, you don't have to use them to get things work on all devices; 如果您正在构建的UI与Apple提供的应用程序一样简单,则不必使用它们来使所有设备都能正常工作;
  2. If the UI is really complicated, you'll end up with so many constraints that in the end no one is able to figure out what is what. 如果用户界面真的很复杂,你最终会遇到很多限制因素,最终没有人能够弄清楚它是什么。 It is fine until there's some huge requirement change to be made with a tight deadline, then the only solution will be work over time. 只要在紧迫的期限内进行一些巨大的需求变更就可以了,那么唯一的解决方案就是随着时间的推移而工作。

It is quite pleasant to build something using Auto Layout with fixed design, it's such an elegant way that everything seems to be in the right place, and totally under your control, and you don't need to write any code at all. 使用具有固定设计的自动布局构建内容非常令人愉快,它是如此优雅的方式,一切似乎都在正确的位置,完全在您的控制之下,您根本不需要编写任何代码。 But as long as changes have to be made, figuring out the relations between all the constraints is harder than reading code. 但只要必须进行更改,找出所有约束之间的关系比阅读代码更难。

For some really complicated layout for multiple devices, the new technology may be a must, but I suppose there's still room for a lot of useful apps that only uses autoresizing mask and code. 对于多个设备的一些非常复杂的布局,新技术可能是必须的,但我想仍然有很多有用的应用程序只有使用自动调整掩码和代码的空间。 It may be a bit shameful to say so, but basically, I hate auto layout. 说这可能有点可耻,但基本上,我讨厌自动布局。

If you want fixed heights for the constraints. 如果你想要约束的固定高度。 Just select your elements in the interfacebuilder, and add height-constraints manually. 只需在界面构建器中选择元素,然后手动添加高度约束。 (The little plus-sign at the bottom, and then height). (底部的小加号,然后是高度)。

Just make outlets to these constraints and manipulate their constant-values if you want fixed heights. 如果你想要固定的高度,只需为这些约束设置出口并操纵它们的常数值。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM