Problems with iPhone UINavigationController (UINavigationBar in the wrong place)

I am in the process of making some changes to the application, including the transition to a navigation-based interface. As part of this change, I wrote a view controller containing UINavigationController. The problem is that for some strange reason UINavigationBarand UIToolbaroperated UINavigationController, are shifted by 20 pixels down from the point where they should be. I was able to create the following example demonstrating the problem:

// MyAppDelegate.m

@implementation MyAppDelegate
@synthesize window = _window;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window.frame = [[UIScreen mainScreen] applicationFrame];
    [self.window makeKeyAndVisible];

    TestController* tc = [TestController new];
    [self.window addSubview:tc.view];

    return YES;
}

@end

// TestController.m

@implementation TestController

- (void)loadView
{
    self.view = [[UIView alloc] initWithFrame:CGRectZero];

    UINavigationController* navController = [UINavigationController new];
    navController.view.backgroundColor = [UIColor blueColor];
    [navController setToolbarHidden:NO animated:NO];

    [self.view addSubview:navController.view];
}

@end

This gives the following result on my machine:

Shot of example

, 20 , . , ( wantsFullScreenLayout, autoresizesSubviews ..) . ( , ), . - , 20 ( ).

!

EDIT: , self.window.frame = [[UIScreen mainScreen] applicationFrame]; , . , ( ). , , , ?

+3
2

, self.window.frame = [[UIScreen mainScreen] applicationFrame];, , 95% . , 5%, , , , - .

, , .

+1

UINavigationController ; , , . , , .

, , , wantsFullScreenLayout NO UINavigationController, . , , , loadView.

0

All Articles