简体   繁体   English

导航栏中的问题未隐藏在另一个视图控制器中

[英]issue in navigation bar not hiding in another view controller

I have used this code in app delegate for making breathdatetableviewcontroller as rootview controller 我已经在应用程序委托中使用此代码将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;
}

so for solving this problem I try to remove navigation bar and putting following code to make brithdatetableviewcontroller as root view controller 因此,为解决此问题,我尝试删除导航栏并放入以下代码以使brithdatetableviewcontroller成为root 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];

but when I use this then its going in to brithdatetableviewcontroller but not working properly 但是当我使用它时它会进入brithdatetableviewcontroller但不能正常工作

so lets just stick to what I did before how can I do something like negivation bar should display when its in rootview but it should get hide when it goes into another viewcontroller and those viewcontroller have there own nevigationbar and buttons. 因此,让我们继续做之前应该做的事情,如何在根视图中显示否定条,但是当它进入另一个ViewController时应该隐藏起来,并且那些ViewController拥有自己的nevigationbar和按钮。

I tried to hide it in another viewcontroller and but thats not working here. 我试图将其隐藏在另一个ViewController中,但这在这里不起作用。

please suggest what should I do to come over this? 请建议我该怎么做才能解决这个问题?

In the viewController 在viewController中

- (void)viewWillAppear:(BOOL)animated
{
    // If you wnat Navigation Bar then
    [self.navigationController setNavigationBarHidden:NO];
    // Else if you don't want
    [self.navigationController setNavigationBarHidden:YES];
}
  1. In your AppDelegate.h class, create a navigation controller : 在您的AppDelegate.h类中,创建一个导航控制器:

    @property(nonatomic,strong)UINavigationController *navController; @property(nonatomic,strong)UINavigationController * navController;

  2. In your APPDELEGATE.M , assign the local Navigation Contooler object to the property. 在您的APPDELEGATE.M中 ,将本地Navigation Contooler对象分配给该属性。

    (UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{ (UIApplication *)应用程序didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

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

    self.navController = nav; self.navController =导航;

    [self.window addSubview:nav.view]; [self.window addSubview:nav.view];

    } }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM