I'm building view without .xib file, just using loadView method. But in the point, when loadView is called, the frame of view is yet unknown. So, I use it just to build view hierarchy without concrete frames. (Than I update view's layout when it's frame is known.)
The question is: should I use [[UIView alloc] init] or [[UIView alloc] initWithFrame:CGRectZero] or may be something else, to initialize view without known frame?
Here is the code:
- (void)loadView
{
UIView *containerView = [[UIView alloc] init];
// or
// UIView *containerView = [[UIView alloc] initWithFrame:CGRectZero];
// or something else?
// ...
self.view = containerView;
[containerView release];
}
- (id)initWithFrame: is the designated initializer for UIView, so you should use that, with a zero-sized rect.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With