iphone – 有没有办法从shouldAutorotateToInterfaceOrientation跳过动画旋转?

我想根据对视图控制器的shouldAutorotateToInterfaceOrientation调用允许方向旋转.但是,我希望它立即这样做并跳过旋转动画(导致角落显示黑色旋转动画,同时整个视图旋转).

有没有人知道是否有一种方法可以指定您希望它立即发生(没有动画)?

最佳答案 为了做你想做的事,你必须手动旋转(和调整大小)你的视图.没有任何属性可以更改为轻松按照您的意愿行事.下面是注册设备旋转事件的代码.

 - (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];当你的视图卸载时.

点赞