OGeek|极客世界-中国程序员成长平台

标题: ios - 在 iOS7.1 中使用 show (push) segue 不会出现导航栏 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 09:43
标题: ios - 在 iOS7.1 中使用 show (push) segue 不会出现导航栏

我有三个设备,三个 iOS 版本。我在 RootViewController 中隐藏了导航栏。然后对于每个 ViewController,我将导航栏显示为

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.userInteractionEnabled = YES;
    // Do any additional setup after loading the view.
    [self.navigationController setNavigationBarHidden:NO];
    CGRect frame = CGRectMake(0, 0, 0, 44);
    UILabel *label = [[UILabel alloc] initWithFrame:frame];
    label.backgroundColor = [UIColor clearColor];
    label.font = [UIFont fontWithName"Helvetica-Bold" size:20.0];
    label.textAlignment = NSTextAlignmentCenter;
    label.textColor = [UIColor blackColor];
    label.text = @"Update Height";
    self.navigationItem.titleView = label;
}

它适用于 iOS8.4 和 iOS9.1 的两台设备,但不适用于 iOS7.1。对于 iOS7.1 设备,如果我将 segue 更改为自定义类型,则会显示导航栏。但是如果我更改为 Show (Push) segue,导航栏就不会出现。 可能是什么问题呢? 我使用了 UIStoryBoard 的 segue。 谢谢



Best Answer-推荐答案


阅读 link然后试试这个

 //hide on current view controller
  - (void)viewWillAppearBOOL)animated {
    [super viewWillAppear:animated];
    [self.navigationController setNavigationBarHidden:YES animated:YES];
}

// show on next view controller
- (void)viewWillDisappearBOOL)animated {
    [super viewWillDisappear:animated];
    [self.navigationController setNavigationBarHidden:NO animated:YES];
}

关于ios - 在 iOS7.1 中使用 show (push) segue 不会出现导航栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33582705/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4