iPhone/iOS SDK:自动旋转主视图,但不自动旋转子视图?
这就是我正在尝试做的事情。
我有一个视图(“primaryView”),由自定义视图控制器控制。 PrimaryView 包含一个滚动视图,其中包含图像。位于滚动视图顶部(而不是内部)的是一个包含一些按钮的小视图(“buttonsView”)。
基本上,当用户旋转手机时,我希望 ButtonView 自动旋转以匹配新方向,但我希望滚动视图保持原样,而不是旋转。
有办法做到这一点吗?现在,primaryView 正在自动旋转,并且同时带有两个子视图(scrollview 和buttonsView),这不好。
谢谢!
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. 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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
除非所有可见视图都同意自动旋转,否则系统不会自动旋转。那么,您可以做的是检测方向变化,并为非旋转视图设置适当的仿射变换,本质上是为了撤消系统的旋转。
您可以使用
willRotateToInterfaceOrientation:duration :
淡出控件,然后didRotateFromInterfaceOrientation:
将它们淡入正确的位置。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, thendidRotateFromInterfaceOrientation:
to fade them back in at the correct location.