我正在开发包含最新SDK和XCode 4.2的iOS 4应用程序。uinavigationcontroller导航栏始终隐藏
我正在使用UINavigationController,我不想显示导航栏。要做到这一点,我使用的AppDelegate此代码:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Override point for customization after application launch.
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
{
self.viewController = [[[ViewController alloc] initWithNibName:@"ViewController_iPhone" bundle:nil] autorelease];
}
else
{
self.viewController = [[[ViewController alloc] initWithNibName:@"ViewController_iPad" bundle:nil] autorelease];
}
navController = [[UINavigationController alloc] initWithRootViewController:self.viewController];
navController.navigationBar.hidden = YES;
self.window.rootViewController = navController;
[self.window makeKeyAndVisible];
return YES;
}
但是,这条线,navController.navigationBar.hidden = YES;
不起作用。我在第一个视图控制器上看不到导航栏,但我在其他视图中看到它。
任何线索?
是的,但如果我这样做,我会看到导航栏占用的空间为空。换句话说,我隐藏了导航栏,但它留下了一个空白空间(视图不适合整个屏幕)。 – VansFannel 2012-03-19 20:37:39
确保将视图控制器的视图autoResizingMask设置为允许灵活的高度。 – jsd 2012-03-19 21:24:17