IOS导航控制器结构

IOS导航控制器结构_第1张图片

(1)这个结构是ios7以上才适用的。

(2)在AppDelegate.m文件中打印UINavigationController的高度:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.
    self.window.backgroundColor = [UIColor whiteColor];
    
    // 1.创建导航控制器
    OneViewController *one = [[OneViewController alloc] init];
    UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:one];
    NSLog(@"%@", NSStringFromCGRect(nav.navigationBar.frame));
    self.window.rootViewController = nav;
    [self.window makeKeyAndVisible];
    return YES;
}

/ 程序获得了焦点就会自动调用这个方法(只要程序获得了焦点,所有控件才能接受触摸事件)
- (void)applicationDidBecomeActive:(UIApplication *)application {
    UINavigationController *nav = (UINavigationController *)self.window.rootViewController;
    NSLog(@"%@", NSStringFromCGRect(nav.navigationBar.frame));
}

注意:在didFinishLaunchingWithOptions方法中获取是得不到正确的值的,因为此时view还没有完全计算好。这点跟android里面也是一样的。

ios6中UINavigationController里面的view和子控制器的view高度跟ios不一样,需要注意。


你可能感兴趣的:(IOS导航控制器结构)