views:

19

answers:

1

From the docs:

Create a root view object that is sized to fit the screen. The root view acts as the container for all other views associated with your view controller. You typically define the frame for this view to match the size of the application window, which itself should fill the screen. However, the view controller also adjusts the frame size as needed to accommodate the presence of assorted views, such as the system status bar, a navigation bar, or a tab bar.

Why should I bother then to set the view's frame to the application window size? I mean... if the view controller adjusts it anyways, then why should I? No...wait... I get it... it makes sense to set it, because subviews created right after that in -loadView might want to know the frame. But doesn't make a lot of sense since that should be done in -viewDidLoad, right?

+1  A: 

The designated initializers for UIView both require a frame be provided either from nib or programatically. This is most likely because all subsequent drawing of any kind depends on the frame. The frame also defines where in the window/super-view the view will appear and even if it should be drawn at all.

In other words, having no frame attribute will break a lot of the class' default methods. even if the frames gets changed later, at any point in time the instance must have a frame attribute.

TechZen