帮我解决任务 - 我有一个不允许旋转其界面的 viewController:
- (BOOL)shouldAutorotate {
return NO;
}
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskPortrait;
}
但我需要旋转出现在这个控制器中的 alertView!因此,如果用户旋转设备,alertView 应该跟随旋转并且主界面保持静止。我尝试订阅通知:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(deviceRotated:) name:UIDeviceOrientationDidChangeNotification object:nil];
但在我deviceRotated:
收到这样有效载荷的通知:
NSConcreteNotification 0x101dc50 {name = UIDeviceOrientationDidChangeNotification; object = <UIDevice: 0x103e640>; userInfo = {
UIDeviceOrientationRotateAnimatedUserInfoKey = 1;
}}
是什么UIDeviceOrientationRotateAnimatedUserInfoKey
?以及如何使用来知道当前的 interfaceOrientation?或者建议一种更好的方法来获取当前方向并旋转alertView。
我试着用
(BOOL)shouldAutorotateToInterfaceOrientation:UIInterfaceOrientation)toInterfaceOrientation
和
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
但这些方法不会在 iOS6 上被调用 :(
另外,还有其他方法可以用来知道设备正在旋转到某个方向吗?提前致谢!PS 我知道这个任务看起来有点傻,但这是客户的要求。对不起 :)