开发者

uidatepicker getting distorted, need help

In my app i am showing UIDatePicker and its getting distorted for some reason.

Well the basic explanation for this to happen is that I am going from landscape mode to portrait mode to show a view that has my UIDatePicker. I am not rotating this view. I am just showing this view from an another view which was in landscape mode. In fact I am not changing the rotation of this view at all.

you can see in the pics below what exactly happening

here is the pic of IB.

uidatepicker getting distorted, need help

and the pic of simulator.

uidatepicker getting distorted, need help

PS: i also tried to create the pick开发者_如何转开发er from code and still the same result. Thanks for your help.


What NR4TR said is right. Since the previous view is in landscape, the picker is getting distorted. You can try saving the IB (containing the picker view) in landscape mode. I hope that will solve the problem.


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!


When datepicker comes from the view that have been in landscape mode it tries to adjust it's frame horizontally automatically and there is no way to prevent it. You have to rotate your view back to portrait and then reinitialize the picker explicitly after changing the orientation.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜