首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >有没有一种方法可以跳过从shouldAutorotateToInterfaceOrientation设置旋转动画?

问有没有一种方法可以跳过从shouldAutorotateToInterfaceOrientation设置旋转动画?
EN

Stack Overflow用户
提问于 2010-07-13 07:21:38
回答 2查看 329关注 0票数 4

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

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

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2010-07-13 08:38:14

要执行所需操作,必须手动旋转视图(并调整视图大小)。您不能更改任何属性来轻松地执行您想要的操作。以下是注册设备旋转事件的代码。

代码语言:javascript
复制
 - (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];。

票数 2
EN

Stack Overflow用户

发布于 2012-04-13 15:14:20

不需要手动旋转。有一种方法可以直接禁用 rotation 。

下面是如何做的答案:https://stackoverflow.com/a/6589568/894671

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/3233032

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档