Take the 2-minute tour ×

How come the iPhone Interface Builder doesn't let me set the X,Y coordinates of a top-level UIView? (Meaning, a view whose direct parent is a UIViewController.) The X and Y boxes on the View Size tab are grayed out. I can change the X,Y values in code at runtime, so why not in the Interface Builder?


share|improve this question
add comment

3 Answers

up vote 4 down vote accepted

Because the view owned by a UIViewController fills the available space in its parent. Its parent will be either a UIWindow or the view controlled by something like a UINavigationController or UITabBarController. It will position the view for you. If you want to control the position of a view, make it a subview of the view controlled by your UIViewController.

share|improve this answer
Top-level views in xibs in general aren't allowed to have the X,Y specified. The best reason I can think of is because they don't have a parent, so what are you even trying to position it inside? –  Kevin Ballard Dec 13 '08 at 23:24
I am very annoyed by this as well. In my view you are not necessarily trying to position it in something, per say, You are setting the default frame for the view, which could then be added in code as a subview to any inclosing view you want to. –  Brad Smith Nov 7 '09 at 2:40
In my case it is a subview of the view controlled by my UIViewController, and I still can't adjust the origin. I'd really like to just have it be bottom-aligned with the view. Picking that in the inspector doesn't seem to have any effect though. –  Joe D'Andrea Jan 31 '11 at 22:59
add comment

I agree this is a missing feature in IB. For basic usage i.e. creating a single top-level view for placement in a standard view controller, of course it's not necessary to set the view origin. However NIBs are designed to be able to hold any number of top-level views in an arbitrary object graph. Since this allows you to use these views in any way you see fit, including programmatically embedding them within any other view, it is an unnecessary constraint to lock out these controls in IB. On a related, but amusing note, if you move a positioned view to the top level, IB itself remembers its relative position for display purposes. However this position is not available once the NIB is loaded.

share|improve this answer
add comment

In Xcode 4.3.2 you can choose size->freeform in the attributes inspector.

share|improve this answer
add comment

Your Answer


