在iOS7.1中,使用show(push)segue不会出现导航栏

时间:2015-11-07 12:22:28

标签: ios objective-c iphone segue uistoryboardsegue

我有三个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。 感谢

1 个答案:

答案 0 :(得分:3)

阅读此link然后尝试此

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

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