回答
UIDeviceOrientation
爲您提供有關物理設備本身的信息,同時UIInterfaceOrientation
告訴你的是顯示視圖的方向。這些不需要匹配;當用戶使用方向鎖或者設備方向朝上時。
您可能想要檢查UIInterfaceOrientation
以及UIViewController
上的旋轉方法以確定視圖何時或應該旋轉。
UIDeviceOrientation
指的是設備的物理方向,而UIInterfaceOrientation
指的是用戶界面的方向。
因此,您需要設置的是autoResizeMask,以便在調整其超級視圖的大小時正確調整視圖的大小。爲視圖設置flexibleWidth和flexibleHeight。檢查http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIDevice_Class/Reference/UIDevice.html
而且 - 是指
UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation]
你上面的代碼是不正確的。您正在將設備方向分配給UIInterfaceOrientation變量。應該是'UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation],或者它應該是'UIInterfaceOrientation orientation = self.interfaceOrientation',其中self是UIViewController。 – mtmurdock
- 1. iPhone屏幕隨機旋轉?
- 2. 旋轉屏幕
- 3. 屏幕旋轉
- 4. 屏幕旋轉
- 5. 屏幕旋轉
- 6. 屏幕旋轉
- 7. Iphone模擬器屏幕旋轉
- 8. iPhone視頻屏幕不旋轉
- 9. 當屏幕旋轉
- 10. 旋轉屏幕TableLayout
- 11. iOS屏幕旋轉
- 12. iPhone屏幕旋轉:我可以強制旋轉90度嗎?
- 13. 的Android旋轉器旋轉屏幕
- 14. 將Iphone屏幕轉換爲Ipad屏幕
- 15. UIWebView接管屏幕旋轉
- 16. EditTextPreference和屏幕旋轉
- 17. OnItemSelectedListener調用屏幕旋轉
- 18. Windows Mobile屏幕旋轉
- 19. nullPointerException在屏幕旋轉後
- 20. android.view.InflateException在屏幕上旋轉
- 21. 屏幕旋轉處理ios
- 22. 等待屏幕旋轉
- 23. ImageView旋轉+填充屏幕
- 24. Android屏幕旋轉問題
- 25. 恢復屏幕旋轉值
- 26. SupportFragmentManager,popbackstack和屏幕旋轉
- 27. Android的屏幕旋轉
- 28. 手動旋轉屏幕
- 29. android中的屏幕旋轉
- 30. 啓用屏幕旋轉android
我希望在一年前知道的事情!我必須使用可以工作的設備方向來解決這個問題的整個解決方案,但是沒有涵蓋幾個角落案例。小時的頭痛......謝謝! – mtmurdock