Loading a UIDatePicker in Landscape on a UINavigationController

前端 未结 6 676
慢半拍i
慢半拍i 2021-02-14 20:44

I have a custom UINavigationController that supports auto-rotate. I also have a UIDatePicker on one of my views that I throw onto the stack of the Navigation controller. The a

6条回答
  •  滥情空心
    2021-02-14 21:03

    I ran into the same problem. When you load a view while already in Landscape orientation the UIPicker is not rendered correctly. I spent several hours trying to find a workaround until I found a fix from this page from Llamagraphics. You add this code in viewDidLoad of the view controller that has the picker:

    for (UIView* subview in myPicker.subviews) {
        subview.frame = myPicker.bounds;
    }
    

    Visit the webpage for more details. Thank you Stuart!

提交回复
热议问题