Ruminations

Code better not harder

Need to Load View

Just found out today that if a UIViewController subclass is constructed programmatically (that is without using Interface Builder),

and, if we don’t create and assign a UIView inside loadView:

1
2
3
4
5

- (void)loadView
{
self.view = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
}

Then, this could ruin the animation transition of presentViewController:animated:completion:. In other words, the transition animation doesn’t occur.

There’s a reason why the documentation says that we need to implement this. I saw at least one project that doesn’t follow this rule.