gpt4 book ai didi

ios - 在 TabbarViewController 中隐藏特定 View Controller 中的状态栏

转载 作者:行者123 更新时间:2023-11-29 10:33:19 36 4
gpt4 key购买 nike

我有一个 TabbarViewController。在一个选项卡中,当导航到特定的 ViewController(详细 ImageView )时,我想隐藏状态栏。我已阅读此链接: How to hide a status bar in iOS?

但在我的例子中,它不起作用,因为我不想在整个应用程序中隐藏状态栏,而只是在特定的 ViewController 中。

有没有办法只在某个标签中隐藏滚动条?

*编辑:我想隐藏状态栏的 ViewController 是一个 PageViewController。是这个问题吗?

最佳答案

    -(void) viewDidAppear:(BOOL)animated{
[super viewDidAppear:YES];
if([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationLandscapeLeft || [UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationLandscapeRight){
if ([self respondsToSelector:@selector(setNeedsStatusBarAppearanceUpdate)]){
[self prefersStatusBarHidden];
[self performSelector:@selector(setNeedsStatusBarAppearanceUpdate)];
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide];
}
else{
// iOS 6
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide];
}

}
else if([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationPortrait || [UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationPortraitUpsideDown){
if ([self respondsToSelector:@selector(setNeedsStatusBarAppearanceUpdate)]){
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide];
[self performSelector:@selector(setNeedsStatusBarAppearanceUpdate)];
}
else{
// iOS 6
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide];
}
}
}

-(UIStatusBarStyle)preferredStatusBarStyle{
return UIStatusBarStyleLightContent;
}
- (BOOL)prefersStatusBarHidden {
return YES;
}

关于ios - 在 TabbarViewController 中隐藏特定 View Controller 中的状态栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28409117/

36 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com