0
votes

I am using Navigation controller.

In my first screen their is no need of NavigationBar. As this is the Home screen.So I am hiding it using this code:

- (void)viewWillAppear:(BOOL)animated
{
   [self.navigationController setNavigationBarHidden:YES];
}

When I push to new screen I am showing the NavigationBar using this code:

 - (void)viewWillAppear:(BOOL)animated
{
   [self.navigationController NO];
}

The problem is when I come back from other screens to my HomeScreen I am getting black screen in place of navigationBar.

Here is the problem in Image:

enter image description here

White color screen is my ViewController which has navigation bar and BLue one has'n Navigation bar. How can I remove the black part.

3
The image link is broken. Check again - ankur140290
I dont have enough repo to post that image...please upvote my question so that i can upload it - user5214391

3 Answers

0
votes

Click on the navigation controller and go to attribute inspector and uncheck the show navigation bar option as shown in the screenshot:

enter image description here

0
votes

try this one

self.navigationItem.hidesBackButton = YES;
0
votes

There is a better way to do it. All you need to do is create a subclass of UINavigationController class. Set the UINavigationControllerDelegate. Add the following method in the class.

    - (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    if([viewController isKindOfClass: [SomeClass class]])
        [self setNavigationBarHidden: NO];
    else
        [self setNavigationBarHidden: YES];
}

OR

-(void)viewWillDisappear:(BOOL)animated
{
    [super viewDidDisappear:animated];
    [self.navigationController setNavigationBarHidden:NO animated:YES];
}
-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [self.navigationController setNavigationBarHidden:YES animated:YES];
}