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

标签 iphone animation autorotate

我想允许方向根据对 View Controller 的 shouldAutorotateToInterfaceOrientation 调用进行旋转。但是,我希望它立即执行此操作并跳过旋转动画(导致整个 View 旋转时角落显示黑色旋转动画的动画。

有谁知道是否有办法指定您希望它立即发生(没有动画)?

最佳答案

为了执行您想要的操作,您必须手动旋转(并调整大小) View 。没有任何属性可以让您轻松更改以轻松执行您想要的操作。下面是注册设备旋转事件的代码。

 - (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: 函数。 当 View 卸载时,您还应该调用 [[UIDevice currentDevice] endGenerateDeviceOrientationNotifications];

关于iphone - 有没有办法从 shouldAutorotateToInterfaceOrientation 跳过旋转动画?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3233032/

相关文章:

ios - swift中的swiftyjson获取不到数据

javascript - CSS-Animation 后如何链接?

iphone - 如何防止 iPhone 自动旋转

ios - UIPageViewController 未调整其 subview Controller 的大小

iphone - 地幔 :cannot find protocol declaration, 'MTLJSONSerializing'

iphone - 通过UIImageView触摸?

iphone - 调用 rootViewController 在内容 View 中切换 View (iOS)

bash - 如何为终端制作动画 bash shell 提示符?

ios - 用户在屏幕外点击 UISearchBar 的完整动画

ios - 在 iOS 7 中触发或延迟自动旋转