【问题标题】:iOS: StatusBar appearance erroriOS:状态栏外观错误
【发布时间】:2026-01-12 20:40:02
【问题描述】:
我有第一个 ViewController 纵向方向和第二个 ViewController 横向方向。第一个ViewController 有状态栏,第二个没有。
然后我从第一个ViewController 中呈现第二个ViewController,它呈现没有状态栏。然后我关闭它我回到第一个ViewController 并有我的状态栏,但视图的位置不正确。
像屏幕一样的视图位置没有状态栏。如何更新?
【问题讨论】:
标签:
ios
objective-c
iphone
uinavigationcontroller
uiinterfaceorientation
【解决方案1】:
首先,试试这个:
在您的景观 VC 中声明以下内容:
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
[[UIApplication sharedApplication] setStatusBarHidden:true];
// you can also try to hide the status bar with animation:
[[UIApplication sharedApplication] setStatusBarHidden:true withAnimation:UIStatusBarAnimationSlide];
}
在您的 portraint VC 中声明以下内容:
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[[UIApplication sharedApplication] setStatusBarHidden:false];
// you can also try to show the status bar with animation:
[[UIApplication sharedApplication] setStatusBarHidden:false withAnimation:UIStatusBarAnimationSlide];
}