iPad - Handling orientation change via reloaded loadView
I have a custom view which needs to be relaid on orientation change. My UIView code can correctly redraw for the any orientation as it express itself 开发者_开发知识库in screen frame size.
But how do I get the loadView method to run on orientation change for the right view to get drawn ?
I put [self.view setNeedsDisplay] in the following rotation handling methods with no luck.
willRotateToInterfaceOrientation:duration
didRotateFromInterfaceOrientation:
Any suggestions would be most welcome.
loadView
actually causes the view to be completely re-created from scratch. It should be sufficient to call setNeedsDisplay
in didRotateFromInterfaceOrientation
on the view that needs to redraw.
If you have to change the layout of your views upon rotation, do so in willAnimateRotationToInterfaceOrientation
(so the changes get animated), and/or set the autoresizingMask
property to the combination of UIViewAutoresizingMask
values that suits your needs.
精彩评论