2

这可能是一个愚蠢的问题,但我以编程方式将 UINavigationController 添加到我的应用程序中。如果可能的话,我只想将它添加到我所有窗口的顶部,除了第一个 .xib。甚至可能只是将其隐藏在我的第一个 .xib 中。有可能做到这一点吗?我想到了我的第一个 .xib 文件,它像封面一样向我的应用程序的其余部分打开,我宁愿那个蓝色条不显示在顶部。我希望我能给你看照片,但还没有足够的代表。谢谢!

下面是我认为可以帮助我为应用程序的每个页面提供后栏的代码:

#import "McCormick_TaylorViewController.h"

@implementation McCormick_TaylorAppDelegate

@synthesize window = _window;
@synthesize viewController = _viewController;

- (void)dealloc
{
    [_window release];
    [_viewController release];
    [super dealloc];
}

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:    
  (NSDictionary *)launchOptions
{
    self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]   
    autorelease];
    // Override point for customization after application launch.
    self.viewController = [[[McCormick_TaylorViewController alloc] 
    initWithNibName:@"McCormick_TaylorViewController" bundle:nil] autorelease];
    UINavigationController * navController = [[UINavigationController alloc]  
    initWithRootViewController:self.viewController];
    self.window.rootViewController = navController;
    [self.window makeKeyAndVisible];

    return YES;
}
4

2 回答 2

1

在你的 McCormick_TaylorViewController 的viewWillApper:方法中

只需使用以下代码...

[self.navigationController setNavigationBarHidden:NO animated:YES];

并在导航栏中的其他视图控制器中显示,然后在另一个视图控制器的 viewWillAppear 中使用下面的代码..

[self.navigationController setNavigationBarHidden:NO animated:NO];
于 2012-06-04T17:49:51.197 回答
0

使用此方法:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:    
(NSDictionary *)launchOptions
 {
 self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]   
 autorelease];
 // Override point for customization after application launch.
 self.viewController = [[[McCormick_TaylorViewController alloc] 
 initWithNibName:@"McCormick_TaylorViewController" bundle:nil] autorelease];
  UINavigationController * navController = [[UINavigationController alloc]  
 initWithRootViewController:self.viewController];
 [navController.navigationBar setHiden:YES]; // hides navigation bar
 self.window.rootViewController = navController;
 [self.window makeKeyAndVisible];
 return YES;
}
于 2012-06-04T17:49:27.410 回答