我勒个去~~~这么诡异,我在我的应用里打印了一把,都是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