保持控件处于横向模式但允许 uitabbar 切换
我有一个 UITabBar 在 iphone 改变方向时切换位置并且工作正常,但我希望第一个选项卡视图中的控件保持静态,无论手机的位置如何。 我觉得我错过了一些明显的东西?
编辑: 基本上,控件始终是横向的,但选项卡栏必须切换方向。这可能吗?
I have a UITabBar switches places when the iphone changes orientation and that works fine, but I want the controls within the view of the first tab to stay static regardless of the position of the phone.
I feel like I'm missing something obvious?
Edit:
Basically, the controls are always landscape but the tab bar must switch orientations. It this possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
对于您不希望控件重新调整的视图,请禁用自动调整大小:
[self.view setAutoresizesSubviews:NO];
。这将阻止所有控件(子视图)响应界面方向更改,但选项卡仍会响应。您可能还需要设置当前视图的 autoresizingMask:[self.view setAutoresizingMask:UIViewAutoresizingNone];
添加:对您不想旋转的所有控件尝试以下操作
For the view in which you don't want the controls to readjust, disable the autoresizing:
[self.view setAutoresizesSubviews:NO];
. This will prevent all controls (subviews) from responding to interface orientation changes and yet the tab will still respond. You might also have to set the autoresizingMask of the current view:[self.view setAutoresizingMask:UIViewAutoresizingNone];
Addition : try the following for all controls you don't want to rotate
的例子
景观或
example of Landscape
OR
不幸的是,这并不完全简单。您不能让 UITabBarController 响应界面更改,同时不让内容视图控制器响应。
但有一种方法可以做到。在内容视图控制器的
willAnimateRotationToInterfaceOrientation:duration:
中,您可以对不想旋转的子视图应用相反的旋转(使用transform
属性)。例如,UIInterfaceOrientationLandscapeLeft 是 90° 顺时针旋转,因此如果您对视图的transform
应用 90° 逆时针旋转,它将看起来没有旋转。如果需要,您可以将内容视图控制器的整个界面包含在 UIView 中,这样您只需反向旋转(并可能调整大小)该视图即可。我不知道在视图控制器的主视图上应用反向旋转是否有效,系统可能会覆盖您对该特定视图的设置。
Unfortunately, it's not exactly straightforward. You can't have the UITabBarController respond to interface changes while not having the content view controller respond.
But there is a way to do it. In the content view controller's
willAnimateRotationToInterfaceOrientation:duration:
, you can apply an opposite rotation (using thetransform
property) to the subviews that you don't want rotated. For example, UIInterfaceOrientationLandscapeLeft is a 90° clockwise rotation, so if you apply a 90° counterclockwise rotation to the view'stransform
it will seem to not have rotated.If you want, you could include the entire interface of the content view controller in a UIView so you just have to counterrotate (and possibly resize) that one view. I don't know whether it would work to apply the counterrotation on the view controller's main view, the system may override your setting for that particular view.