中定义检测UIViewController上的接口旋转我有一个UIViewController处理主视图上的几个UIImageViews。在底部是一个UIToolbar,有几个项目可以互动。即使没有在 - (NSUInteger)supportedInterfaceOrientations
现在,当我旋转设备,我不希望viewController旋转,但只是UIImageViews。换句话说,底部的工具栏位于左侧(或右侧),但imageViews会正确旋转。
所以,通过使用这些方法
- (BOOL)shouldAutoRotate {
return YES;
}
与
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskPortrait;
}
和
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
// rotate the image views here
}
在设备上的任何转动将不会被执行相结合,因为只有一个接口取向是支持(UIInterfaceOrientationMaskPortrait
)。但是当我添加另一个界面方向以支持supportedInterfaceOrientations
-方法时,视图控制器也将旋转。
即使只支持一个方向,我如何检测视图控制器的旋转?或者还有另一种可能性,可以根据不断变化的设备方向旋转UIViews?
感谢您的帮助!
找到了答案 - 当然 - 10秒后在这里:ht TP://stackoverflow.com/questions/14387735/can-i-observe-when-a-uiviewcontroller-changes-interfaceorientation – uruk