views:

975

answers:

1

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?

Thanks.

+2  A: 

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.

Alex
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
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