UITableView in UINavigationController gets under Navigation Bar after rotation

前端 未结 8 875
清酒与你
清酒与你 2020-12-21 06:10

This is Portrait:

This is Landscape

I\'ve tried this on rotation with no success:

self.tableView.autoresizesSubviews = YE         


        
8条回答
  •  鱼传尺愫
    2020-12-21 07:02

    When using a custom view controller as root, which manages other view controllers itself, then it is responsible to forward all rotation events to the currently active sub-controller (if I may call it like that). These events are:

    – willRotateToInterfaceOrientation:duration:
    
    – willAnimateRotationToInterfaceOrientation:duration:
    
    – didRotateFromInterfaceOrientation:
    
    – willAnimateFirstHalfOfRotationToInterfaceOrientation:duration:
    
    – didAnimateFirstHalfOfRotationToInterfaceOrientation:
    
    – willAnimateSecondHalfOfRotationFromInterfaceOrientation:duration:
    

    So in the case of a navigation controller, managed by your custom root controller, forwarding – willAnimateRotationToInterfaceOrientation:duration: to the navigation controller fixes the issue with the wrong navigation bar height when rotating.

提交回复
热议问题