UINavigationController *navController = [[UINavigationController alloc] initWithRootController:rootController];
这个时候navController.view 的高度是480,到了rootController后,self.navigationController.view的高度怎么又变成了460???
确实是有个地方修改了frame,我还是有个疑问,既然navigationcontroller 的view高度是480,为什么导航是从status bar下面开始显示的?? 是不是在navigationController的initWithRootViewController:rootViewController方法里,把navigationController的view frame修改成rootViewController的view frame了,不然解释不通啊
确实是有个地方修改了frame,我还是有个疑问,既然navigationcontroller 的view高度是480,为什么导航是从status bar下面开始显示的?? 是不是在navigationController的initWithRootViewController:rootViewController方法里,把navigationController的view frame修改成rootViewController的view frame了,不然解释不通啊?
我勒个去~~~这么诡异,我在我的应用里打印了一把,都是480的。但是你提到的情况,很可能是某个操作影响了status bar,造成navController的高度变了。因为iPhone里只有status bar的高度是20像素的。
能贴一下其他代码么?看看问题出在哪里
一下是我的代码和输出结果:
TestAppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease]; // Override point for customization after application launch. self.window.backgroundColor = [UIColor whiteColor]; [self.window makeKeyAndVisible]; self.viewController = [[TestViewController alloc] init]; self.navController = [[UINavigationController alloc] initWithRootViewController:self.viewController]; NSLog(@"height:%f", self.navController.view.frame.size.height); [self.window addSubview:self.navController.view]; NSLog(@"height:%f", self.navController.view.frame.size.height); return YES; }
TestViewController.m
- (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. NSLog(@"height:%f", self.navigationController.view.frame.size.height); }
三个NSLog打印出来的都是480
2012-09-19 23:43:13.561 NAVTest[1132:c07] height:480.000000 2012-09-19 23:43:13.562 NAVTest[1132:c07] height:480.000000 2012-09-19 23:43:13.563 NAVTest[1132:c07] height:480.000000