iPhone/iOS SDK: Autorotate main view, but not child view?
Here's what I'm trying to do.
I have a single view ("primaryView"), controlled by a customized view controller. primaryView contains a scrollview, which contains an image. 开发者_Go百科Sitting on top of the scroll view (NOT inside it) is a small view ("buttonsView") containing a few buttons.
Basically, when the user rotates the phone, I want buttonsView to autorotate to match the new orientation, but I want the scrollview to remain exactly as it is, and NOT rotate.
Is there a way to do this? Right now, primaryView is autorotating, and taking both subviews (the scrollview and buttonsView) with it, which is no good.
Thanks!
The system will not autorotate unless all visible views consent to autorotation. What you can do, then, is to detect orientation changes, and set an appropriate affine transform for the non-rotating views, essentially to undo the system's rotation.
You can use willRotateToInterfaceOrientation:duration:
to fade out the controls, then didRotateFromInterfaceOrientation:
to fade them back in at the correct location.
精彩评论