Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

- UIWindow setRootViewController: equivalent in pre 4.0

I started iphone development with 4.0 sdk. I am trying to make my app compatible with 3.2. I realized that -[UIWindow setRootViewController:] is added to the sdk in version 4.0. So instead of it, what should I use in pre 4.0 releases? In other words, what does rootViewController property do in essence except assigning window's primary subview? If I extend UIWindow and redefine the method as below, would it be a problem in future?


- (void) setRootViewController:(UIViewController *)controller
{
    if (systemVersion < 4.0)
    {
        while(self.subviews.count > 0)
             [[self.subviews objectAtIndex:0] removeFromSuperview];
        [self addSubview:controller.view];
    }
    else [super setRootViewController:controller];
}
like image 491
ozan k Avatar asked Dec 06 '10 21:12

ozan k


1 Answers

We used to do this:

    [window addSubview:[navigationController view]];

That is what it used to be in Apple's samples and still works ok.

like image 162
bioffe Avatar answered Sep 27 '22 22:09

bioffe