帮我解决了任务 - 我有一个不能转动它的接口的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我知道这项任务似乎有点愚蠢,但这是客户的要求。对不起:)对不起:)
谢谢,这是最简单的方法。 – Stas 2013-03-14 09:46:09