是否可以關閉自動旋轉動畫?我希望它旋轉,但我不想讓動畫發生(像即時切換)。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