0

我有一个奇怪的问题。我有两个视图控制器。一个 homeViewController 和一个 settingViewController。

homeViewController 没有导航栏,而 settingViewController 有。

现在的问题是当我推动 settingViewController 并从中返回时,我的 homeViewController 视图的高度变小了。(视图的高度 - 导航栏高度)

(不想手动调整框架)

// homeViewController
-(void) settingButtonPressed {

    SettingsViewController *svc = [[SettingsViewController alloc] init];
    [self.navigationController pushViewController:svc animated:YES];
}

// settingViewController
-(void) viewWillAppear:(BOOL)animated {

    [super viewWillAppear:animated];
    self.navigationController.navigationBarHidden = NO;
    self.navigationController.navigationBar.barStyle = UIBarStyleDefault;
    self.navigationItem.hidesBackButton = NO;
    [UIApplication sharedApplication].statusBarHidden = YES;

    UIInterfaceOrientation statusBarOrientation =[UIApplication sharedApplication].statusBarOrientation;

    [self willAnimateRotationToInterfaceOrientation:statusBarOrientation duration:0.0];
}

-(void) viewWillDisappear:(BOOL)animated {

    [super viewWillDisappear:animated];
    self.navigationController.navigationBarHidden = YES;
}

请建议解决它。

4

3 回答 3

0

写在homeVC.m

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];

    self.navigationController.navigationBarHidden = YES;
}

并在设置VC.m

- (void)viewDidDisappear:(BOOL)animated {
    [super viewDidDisappear:(BOOL)animated];   

    self.navigationController.navigationBarHidden = YES;
}
于 2013-09-13T05:54:15.987 回答
0

与其尝试管理视图中导航栏的可见性,不如尝试在导航控制器的委托中管理它。

于 2013-09-13T05:58:41.920 回答
0

尝试设置ViewController 的弹出动作方法

self.navigationController.navigationBarHidden = YES;
于 2013-09-13T06:23:12.190 回答