Why Can't I Resize my Views in Interface Builder?
Dec 04, 2010 09:29

When I was getting started in iPad development for Remembary, this confounded me for days. Whenever I created a new .xib for a project, it would be stuck at the full 768x1004 size and there didn't seem to be any way to change it.

iPhone development tends to have overlapping views that take up the full screen, and the development tools still have that assumption built into them. Many iPad apps involve building popovers of varying sizes for control panels or image viewers or asset browsers - but newly-minted .xibs seem to be stuck in full-screen and there's no checkbox for "Don't fill whole screen".

The magic setting that fixes this is almost comically obscure: The top of the "Attributes Inspector" there is a section called "Simulated User Interface Elements" (yes, that's right - simulated - which would seem to imply that they don't really matter, right?). The second option in this section is Status Bar, which has exactly two settings, "Black" and "Unspecified". The default is "Black" but you want to change it to "Unspecified". Now you can resize the view to your heart's content.

Obvious, right?

Part of the problem is that the Interface Builder is part sexy graphical design tool and part object manager. The Attributes Inspector and other tools are actually manipulating the various parameters of the underlying objects. The "Status Bar" menu is a visual interface for the "statusBarStyle" property, which can be UIStatusBarStyleDefault or UIStatusBarStyleBlackOpaque. The iPhone also supports UIStatusBarStyleBlackTranslucent. So this requires a menu to pick between the different elements. Checkboxes only refer to boolean properties with a clear true or false.

From an application architecture point of view, this all makes sense: the Status bar can have one of several options, all views should default to having a status bar, and if they have a status bar they shouldn't be allowed to be resized. This worked fine on the iPhone when most views took up the whole screen - but it's confusing on the iPad, where that isn't the case.

While it would be great to have a "Make Resizable" or "Fill Screen" checkbox somewhere, that wouldn't properly reflect the underlying object model.

This probably wouldn't be so maddening if Interface Builder wasn't otherwise so sexy and generally intuitive - if it was more like some Java AWT monstrosity or big ugly XML configurator (which of course, deep down it is). XCode 4 looks like it's going to be even sexier, with tighter integration between the code and the interface - I wonder if it's going to still have these quirks?

Momento and Remembary
Dec 03, 2010 10:45
Remembary is Sponsoring PodcampHFX
Jan 18, 2011 04:57