问题描述
在活动呼叫和应用程序布局期间遇到状态栏问题.
Faced with an issue with status bar during active call and application layout.
我正在使用自动版式.当我运行该应用程序,然后开始通话时,一切正常,使用更改后的状态栏可以正确缩放用户界面.
I'm using autolayouts. When I run the app, and then start a call, all works fine, the UI is scaled properly with changed status bar.
但是,如果我先打一个电话然后运行该应用程序,则应用程序屏幕将移动20 pt到底部,就像它们对新状态栏没有反应一样.即使我关闭通话,UI也会移至底部.
But if I first start a call and then run the app, application screens moved for 20pt to the bottom, like if they did not react on new status bar. And even if I will turn off the call, the UI will be moved to bottom.
也许有人知道如何解决?
Maybe somebody know how o fix that?
推荐答案
这很简单,当您为视图赋予约束时,就可以根据视图控制器的TLG(顶部布局指南)来赋予它们约束.现在,当发生呼叫时,状态栏将调整大小,TLG会因状态栏的改变以及视图的移动而改变.
This is easy, when you gave the constraints to your views you gave them with respect to the TLG(Top Layout Guide) of your View Controller. Now when a call occurs the status bar resizes due to which the TLG changes and resulting of which the views move.
为避免这种情况,您可能要相对于Superview的顶部给出视图的顶部约束.现在,在这种情况下,视图的约束不依赖于状态栏大小的更改而改变的TLG,因此它们在呼叫或更改状态栏大小的任何其他事件期间都不会更改.
To prevent this you might wanna give the top constraint of your view with respect to the Top of the superview. Now in this case views's constraints are not dependent on TLG which changes on change of status bar size, therefore they do not change during a call or any other event which change the size of the status bar.
这篇关于iOS App布局与呼叫状态栏错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!