3

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.

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

on iPhone 5 I want it to be
400px
148px

and on iPhone 4 :
358px
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

jscs
  • 63,694
  • 13
  • 151
  • 195
Mathieu
  • 1,175
  • 4
  • 19
  • 34
  • 2
    This won't answer your question, but I encourage you to watch the WWDC session videos on Auto Layout. AL does take a decent amount of adjusting, but I think you'll like it for most tasks once you're comfortable with it. – sudo rm -rf Oct 16 '12 at 03:45
  • I started to watch'em, for the moment I disabled autolayout but I definitely want to use it when I'll understand how it works – Mathieu Oct 16 '12 at 10:50

3 Answers3

3

I hate the new AutoLayout in Interface Builder. The first thing I do is disable it. Just disable it by clicking on File's Owner > Show File Inspector, then untick Use AutoLayout.

WrightsCS
  • 50,551
  • 22
  • 134
  • 186
1

The problem I found about Auto Resizing and Size Classes is that the purpose of them is to handle complex UI layouts, so:

  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;
  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.

superarts.org
  • 7,009
  • 1
  • 58
  • 44
0

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.

ullstrm
  • 9,812
  • 7
  • 52
  • 83