2
votes

I have just migrated to Xcode 4 and Interface Builder is not quite working the same as it did in Xcode 3. As I am designing my user interface, whenever I resize a view (including the window itself) that contains any sub-views such as an NSBox or a custom view, all of the sub-views rescale with it!

I can see why this makes sense, because it shows how the application will act during runtime, but it is very annoying during design time; every time I want to add some more controls to the window I need to expand the window, then resize all of the subviews back to how they were, then add the new controls. It's driving me insane!

I have been looking for a way to stop this from happening but cannot seem to do so. First I thought that since it is emulating runtime behaviour that if I uncheck 'Autoresizes Subviews' in the windows view properties, that would stop the autoresizing. But that didn't work.

I then found this in the Interface Builder User Guide:

Interface Builder offers two behaviors for resizing windows:

  • You can resize just the window.

  • You can resize the window and all of its contents.

By default, resizing a window resizes just the window. To resize the window and its contents, hold down the Command key while you click and drag the window’s resize handle. Holding down the Command key causes Interface Builder to apply the autoresizing behavior currently in place for the window’s contained views. This technique lets you view the runtime resizing behavior of your window or scale the window and its contents to a desired size.

You can toggle the default resizing mode by choosing Layout > Live Autoresizing from the menu. When toggled, holding down the Command key resizes just the window.

I couldn't find this in the menu, but instead: Editor > Canvas > Live Autoresizing (Perhaps the documentation is a little out of date in that respect?)

The funny thing is that it was disabled. I toggled it on and off any way just to make sure, but still the auto resizing is happening!

Has anybody else encountered this issue, or is it that something was changed in Xcode 4 that I am missing out on?

2

2 Answers

0
votes

Xcode4 is very different.

You can resize the window and all of its contents.

In you View Object -> Attributes inspector -> autoresizes Subviews enter image description here

0
votes

Aha! I have just found the answer online:

http://www.goodbyehelicopter.com/2012/02/arggh-xcode-4-3-auto-layout-is-on-by-default-how-to-turn-off-auto-layout/

The problem was that in Xcode 4.3 or greater the 'Auto Layout' feature is enabled by default!

To disable this, go the the nib's file inspector and under 'Interface Builder Document', uncheck 'Use Auto Layout'

By disabling this feature, Interface Builder appears to work a lot more like it did in Xcode 3. It also brings back the familiar 'struts and strings' style autosizing options, rather than the new 'constraints' feature that I have not had chance to get my head around yet!