1

我已在应用程序委托中使用此代码breathdatetableviewcontroller作为rootview controller

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{

    name =[[NSString alloc]init];
    birthdate =[[NSString alloc]init];
    phone =[[NSString alloc]init];
    email =[[NSString alloc]init];
    image =[[NSString alloc]init];

    birthDateTableViewController =[[BirthDateTableViewController alloc]initWithNibName:@"BirthDateTableViewController" bundle:nil];

    navController1 = [[[UINavigationController alloc]initWithRootViewController:birthDateTableViewController]autorelease];

    [window addSubview:navController1.view];
    [window makeKeyAndVisible];
      [FBProfilePictureView class];


    [[UIApplication sharedApplication]setStatusBarStyle:UIStatusBarStyleBlackOpaque];


    self.databaseName = @"birthdateDatabase.sqlite";
    NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentDir = [documentPaths objectAtIndex:0];
    self.databasePath = [documentDir stringByAppendingPathComponent:self.databaseName];
    [self createAndCheckDatabase];
    //  sleep(5);

    if (sqlite3_open([[self dataFilePath] UTF8String], &database1) != SQLITE_OK)
    {
        sqlite3_close(database1);
        NSLog(@"Failed to open db.");
    }
    else
        NSLog(@"Open DB");


    return YES;
}

所以为了解决这个问题,我尝试删除导航栏并将以下代码制作brithdatetableviewcontrollerroot view controller

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.
    self.birthDateTableViewController = [[BirthDateTableViewController alloc] initWithNibName:@"BirthDateTableViewController" bundle:nil];
    self.window.rootViewController = self.birthDateTableViewController;
    [self.window makeKeyAndVisible];

但是当我使用它时,它会进入 brithdatetableviewcontroller 但无法正常工作

因此,让我们坚持我之前所做的事情,当它在 rootview 中时应该显示 negivation bar,但是当它进入另一个 viewcontroller 并且那些 viewcontroller 有自己的 nevigationbar 和按钮时应该隐藏它。

我试图将它隐藏在另一个视图控制器中,但这在这里不起作用。

请建议我该怎么做才能解决这个问题?

4

2 回答 2

0

在视图控制器中

- (void)viewWillAppear:(BOOL)animated
{
    // If you wnat Navigation Bar then
    [self.navigationController setNavigationBarHidden:NO];
    // Else if you don't want
    [self.navigationController setNavigationBarHidden:YES];
}
于 2013-04-06T07:40:40.827 回答
0
  1. 在您的AppDelegate.h类中,创建一个导航控制器:

    @property(nonatomic,strong)UINavigationController *navController;

  2. 在您的 APPDELEGATE.M中,将本地 Navigation Contooler 对象分配给该属性。

    (UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{

    UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:< MYViewController >];

    self.navController = 导航;

    [self.window addSubview:nav.view];

    }

于 2014-01-09T07:41:12.560 回答