UIViews ending up beneath tab bar

后端 未结 4 1573
没有蜡笔的小新
没有蜡笔的小新 2020-12-15 09:36

In my app, I aligned a label the standard amount from the bottomLayoutGuide using autolayout. When the app first starts everything is layed out as I wanted but when I switch

4条回答
  •  时光说笑
    2020-12-15 10:25

    This happens due to a bug in iOS7, where the bottom layout guide is incorrectly set to height 0 instead of the tab bar's height. When you rotate the device, the bottom layout guide is set correctly.

    Currently, your best option is to disable bottom extended layout:

    - (UIRectEdge)edgesForExtendedLayout
    {
        return [super edgesForExtendedLayout] ^ UIRectEdgeBottom;
    }
    

    Do this for each view controller that is displayed from the tab bar controller. Remember to set the tab bar view controller's background color to whatever suits your application.

    Make sure to open a bug report at https://bugreport.apple.com

    To elaborate a little more, it seems viewDidLayoutSubviews is called twice when switching view controllers. First time, everything is set correctly, but the second time bottom layout guide height is 0. You can see from the stack trace that the first one comes from tab bar layout, while the second call is from a scheduled CALayer layout, which is incorrect.

提交回复
热议问题