我希望允许方向按照对视图控制器的shouldAutorotateToInterfaceOrientation调用进行旋转。但是,我希望它立即这样做,并跳过旋转动画(当整个视图旋转时,导致角落显示黑色旋转动画的动画)。
有没有人知道是否有一种方法可以指定您希望它立即发生(而不是动画)?
发布于 2010-07-13 08:38:14
要执行所需操作,必须手动旋转视图(并调整视图大小)。您不能更改任何属性来轻松地执行您想要的操作。以下是注册设备旋转事件的代码。
- (void)viewDidLoad {
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationChanged:)
name:UIDeviceOrientationDidChangeNotification object:nil];
//Whenever the device orientation changes, orientationChanged will be called
}
- (void)orientationChanged:(NSNotification *)notification
{
UIDeviceOrientation deviceOrientation = [UIDevice currentDevice].orientation;
//Based upon which orientation the device is in, update your View rotations.
//A simple view.transform = CGAffineTransformMakeRotation(whatever); will work well.
}我认为您应该完全删除shouldAutoRotateToInterfaceOrientation:函数。您还应该在卸载视图时调用[[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications];。
发布于 2012-04-13 15:14:20
不需要手动旋转。有一种方法可以直接禁用 rotation 。
https://stackoverflow.com/questions/3233032
复制相似问题