2
votes

I have three devices with three iOS version. I hide the navigation bar in RootViewController. Then for each ViewController, I display the navigation bar as

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

It works on two devices with iOS8.4 and iOS9.1, but not for iOS7.1. For the iOS7.1 device, if I change the segue to custom type, the navigation bar is displayed. But if I change to Show (Push) segue, the navigation bar doesn't show up. What could be the problem? I used segue from UIStoryBoard. Thanks

1
r u sure the navigation bar is not made hidden on storyboard ? - Teja Nandamuri

1 Answers

3
votes

read this link and then try this

 //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];
}