CurrentViewController hides navigation bar in iOS

I am trying to show a navigation controller when I submit PresentViewControllerto navigate the screen. I solved this problem, but I ran into another problem. The problem is when I click on the screen that the back button is displayed on the next screen with the navigation controller. But when I try PresentViewController, this time navigation bar is visible, but not backward.

Here is my code:

 - (IBAction)clickMeAction:(id)sender
 {
    ViewController1 *viewcontrol = [self.storyboard instantiateViewControllerWithIdentifier:@"ViewID"];
    //[self.navigationController pushViewController:viewcontrol animated:YES]; // this is for push to viewcontroller


    UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:viewcontrol];
    [self presentViewController:navigationController animated:YES completion:nil]; // This is for modalviewcontroller
 }

Here is my conclusion:

with pressing:

enter image description here

with modal:

enter image description here

Please help me.

Thank.:)

+4
source share
1 answer

Meted 1:

[navigationController presentViewController:navigationController animated:YES completion:^{ [navigationController setNavigationBarHidden:YES animated:NO]; }];

Methed 2: in presentViewController

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

-1
source

All Articles