是否可以关闭自动旋转动画?我希望它旋转,但我不想让动画发生(像即时切换)。iphone autorotation动画
回答
只需添加以下代码来覆盖标准的旋转动画:
- (void)viewDidLoad
{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didRotate:) name:UIDeviceOrientationDidChangeNotification object:nil];
}
- (void)didRotate:(NSNotification *)notification {
orientation = [[UIDevice currentDevice] orientation];
if(orientation == UIDeviceOrientationUnknown || orientation == UIDeviceOrientationFaceDown || orientation == UIDeviceOrientationFaceUp){
orientation = UIDeviceOrientationPortrait;
}
[[UIApplication sharedApplication] setStatusBarOrientation:orientation animated:NO];
[self positionScreenElements];
}
这个答案效果很好,但是我在聚焦文本框时遇到了一些问题。如果iPad平放在桌面上,那么键盘在屏幕外显示一半 - 非常奇怪。 问题在于设备方向也可能未知,面朝上或面朝下,其中没有一个对应于状态栏方向。检查这些状态使这个完美。 非常感谢尼尔斯为我挽救了这个解决方案:) – 2012-06-23 03:21:03
+1 adam为你贡献:] – 2012-06-23 08:21:30
什么是“定位”? – Morkrom 2013-08-28 21:43:07
如果你真的需要,只是用setAnimationsEnabled
UIView
的:
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
[UIView setAnimationsEnabled:NO]; // disable animations temporarily
}
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
[UIView setAnimationsEnabled:YES]; // rotation finished, re-enable them
}
它的伎俩我。当然,除非你有充分的理由去做,否则不建议这样做。
这太好了!谢谢! – 2012-04-13 07:05:06
@Nils Munch不幸的是,这不能正常工作,setStatusBarOrientation期望UIInterfaceOrientation
不UIDeviceOrientation
和铸造是不好的做法。纠正我,如果我错了
- 1. iPhone Autorotation - 禁用视图旋转动画但是转换到另一个屏幕
- 2. iphone html动画?
- 3. iPhone UILabel动画
- 4. 动画ipad/iphone
- 5. 动画UIImageView iPhone
- 6. iphone iads动画
- 7. UINavigationController和autorotation
- 8. UINavigation Controller和Autorotation
- 9. Autorotation And resizing
- 10. iPhone Image Zoom动画
- 11. iphone连续动画
- 12. UIView的动画iPhone
- 13. 缩放动画iPhone
- 14. iphone中的动画
- 15. iPhone相册动画
- 16. iPhone动画球体
- 17. 加速iPhone动画
- 18. iphone - 错误动画
- 19. iPhone:矢量动画
- 20. xcode iphone球动画
- 21. Iphone手写动画
- 22. iPhone查看动画
- 23. 两个UITabBarControllers和Autorotation
- 24. iPhone视图移动动画
- 25. 如何在cocos2d中暂停AutoRotation(使用UIViewController的AutoRotation)?
- 26. (iphone)autorotation不会改变我的视图尺寸
- 27. iPhone - 动画TabBarController开关
- 28. iPhone多子视图动画
- 29. iPhone垃圾桶吸动画
- 30. 链接动画(iPhone/MonoTouch)
动画是它的美丽! – 2010-06-01 12:09:24
嗯,我已经设置好了,使得BG图像根据方向改变为图像的水平或垂直版本,并且当图像改变时旋转动画引起毛刺,但是我玩了它并且看起来像它无论如何,好吧。 – Brodie 2010-06-01 16:31:55