当我呈现 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
}
这是我的输出:
通过推送:
模态:
请帮帮我。
最佳答案
方法一:
[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/