UINavigationController mis-sizes contained view

Status
Not open for further replies.
Here's a snippet that illustrates the issue. When the phone is in landscape, the button's top corners aren't visible. How come?

Code:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    UIViewAutoresizing ar = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
    
    window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
    [window makeKeyAndVisible];
    window.rootViewController = self; //The delegate is a controller
    
    UIViewController* vc = [[UIViewController new] autorelease];
    
    nc =  [[UINavigationController alloc] initWithRootViewController:vc];
    CGRect r = self.view.frame;
    r.origin = CGPointZero;
    nc.view.frame = r;
    [self.view addSubview:nc.view];
    
    nc.view.autoresizingMask = ar;
    
    UIView* b = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    r.size = vc.view.frame.size;
    b.frame = r;
    b.autoresizingMask = ar;
    [vc.view addSubview:b];
    return YES;
}

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
    return YES;
}
 
Status
Not open for further replies.