I have a UIViewController that shows and hides the status bar. Hiding the status bar works no problem, however when I show the status bar using:
[[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationSlide];
Causes the contents of the View to move up 20px so it ends up under the status bar. I dont know what else I can provide but this description, all that happens is when I hide the status bar, there is 20px of white space at the top where the status bar would be (this is what I want) but when I show the status bar the view moves up under the status bar (this is not what I want). The desire is to show and hide the status bar without effecting the UIViewController and its contents.
答案 0 :(得分:3)
我有同样的问题。我设法在故事板中修复它。
正在向上移动的视图的顶部约束设置为顶部布局指南。我将其更改为指向 Superview.Top ,视图停止移动。
要在顶部布局指南中明确使用Superview,您需要使用Pin(故事板左下角的按钮)并在设置约束之前取消选中" Constrain to margin"
答案 1 :(得分:1)
我通过删除此ViewController上的自动布局并在以下位置手动设置视图布局来解决此问题:
-(void)viewDidLayoutSubviews
似乎解决了这个问题。为@ThatGuy欢呼,让我朝着正确的方向前进。