ios - PresentViewController 在 iOS 中隐藏导航栏

标签 ios uinavigationcontroller

当我呈现 PresentViewController 以导航屏幕时,我试图显示导航 Controller 。我解决了这个问题,但我遇到了另一个问题。问题是当我按下一个屏幕时,时间后退按钮在带有导航 Controller 的下一个屏幕上可见。但是当我尝试 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
 }

这是我的输出:

通过推送:

enter image description here

模态:

enter image description here

请帮帮我。

最佳答案

方法一:

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

方法二:在presentViewController中

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

关于ios - PresentViewController 在 iOS 中隐藏导航栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25519010/

相关文章:

IOS扫描经典蓝牙-获取地址-IBeacons

ios - Root View Controller 的确切含义

ios - 在 titleView 中查看 Swift UITapGesture 不工作

ios - 根据模式/大小写更改 navigationBar.title?

Swift:不能在函数内使用 navigationController.pushViewController

ios - Xcode 应用程序不会在我第一次运行时在 ipod 上启动,但会在第二次运行(没有清理/构建)

ios - 使用 AutoLayout 的 UIScrollView 灵活布局

ios - PF LoginViewController 如何在登录界面和主页之间切换? swift

iphone - 我们如何为 GLFloat 赋值以在 iPhone 应用程序中画一条线?

iphone - 为循环 UIView 动画 block 添加随机性