PresentViewController在iOS中隐藏导航栏

时间:2014-08-27 04:39:40

标签: ios uinavigationcontroller

当我出现PresentViewController以导航屏幕时,我正在尝试显示导航控制器。我解决了这个问题,但我遇到了另一个问题。问题是当我按下导航控制器在屏幕上显示时间后退按钮在下一个屏幕上可见时。但是当我尝试PresentViewController时,那个时间导航栏是可见的,但不是后退按钮。

这是我的代码:

 - (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
 }

这是我的输出:

用push:

enter image description here

with modal:

enter image description here

请帮帮我。

1 个答案:

答案 0 :(得分:-1)

方法1:

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

方法2:在presentViewController中

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