仅在第一个.xib文件上隐藏UINavigationController

时间:2012-06-04 17:44:14

标签: iphone macos xcode4.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;
}

2 个答案:

答案 0 :(得分:1)

在你的McCormick_TaylorViewController的viewWillApper:方法

只使用下面的代码...

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

并在导航栏中的其他视图控制器中显示然后在另一个viewController的viewWillAppear中使用波纹管代码..

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

答案 1 :(得分: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;
}