回答
下水
應用在iPhone OS中通常 推出肖像模式以匹配主屏幕的 方向。如果您 有兩個 縱向和橫向模式運行的應用程序,你的應用程序 應始終 肖像模式開始啓動,然後讓 其視圖控制器旋轉 接口需要基礎上, 設備的方向。但是,如果您的 應用程序僅在橫向模式 中運行,則必須執行 以下步驟,以使其最初以橫向 橫向啓動。
在應用程序的Info.plist文件中添加
UIInterfaceOrientation
項並將其值設置爲
風景模式。對於景觀
方向,您可以將該值設置這個關鍵的
到
UIInterfaceOrientationLandscapeLeft
或
UIInterfaceOrientationLandscapeRight.
鋪陳在橫向模式下您的意見,並確保他們的 自動尺寸選項設置正確 。
覆蓋您的視圖控制器的
shouldAutorotateToInterfaceOrientation:
方法和返回是隻爲
所需的橫向和NO
人像方向。
編輯的plist僅支持風景,然後確保在每一個的UIViewController/uitabbar等,在shouldAutoRotateToInterfaceOrientation
,則return
說return ((interfaceOrientation == UIInterfaceOrientationLandscapeLeft) || (interfaceOrientation == UIInterfaceOrientationLandscapeRight));
。
甚至更好: if(UIInterfaceOrientationIsLandscape(interfaceOrientation)){return YES; }返回NO; – Sangraal 2010-12-22 20:15:24
甚至更短:return(UIInterfaceOrientationIsLandscape(interfaceOrientation)) – 2011-07-21 13:32:29
沒有圓括號的情況下更短:-) – 2012-02-16 20:53:47
你也只是這一切縮短
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}
對於簡短和甜蜜的解決方案。 – 2012-02-28 05:24:08
爲了讓您的應用程序風景模式只有,你應該使用「支持的界面取向」。 (Targets -> YourApp -> Supported Interface Orientations -> Landscape Left & Right
)
您還應該通過附加的價值觀Landscape (left home button)
和Landscape (right home button)
的Supported interface orientations
鍵設置的應用程序在應用程序的Info.plist
文件()的方向。
您可以使用willRotateToInterfaceOrientation
和/或didRotateFromInterfaceOrientation
來處理方向更改。
shouldAutorotateToInterfaceOrientation
從iOS 6的進出棄用。
返回UIDeviceOrientationLandscapeLeft/Right
爲shouldAutorotateToInterfaceOrientation
應該讓你的應用程序的 「風景」:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
而且還可能會改變你的應用程序的Info.plist
和View Orientation
(如上所述)。
此外,我建議在更改視圖的定向Landscape
屬性督察。
當時沒有存在,但很高興知道更新的選項 – 2012-07-19 20:28:10
- 1. iPad應用程序並不適用於橫向模式
- 2. 橫向模式不適用於Android Studio
- 3. AVCam不適用於橫向模式
- 4. 只適用於視頻的橫向模式
- 5. 適用於iPhone的縱向方向和適用於iPad的橫向方向的通用應用程序
- 6. iPad - 用於橫向和縱向模式的不同設計
- 7. 適用於iPad的通用應用程序和橫向方向
- 8. iPhone應用程序在橫向模式下打開iPad上
- 9. iPhone橫向模式問題
- 10. iPad狀態欄方向鎖定(僅適用於橫向/縱向)
- 11. 適用於iPad的橫向和縱向圖形
- 12. 只在橫向模式
- 13. UIModalPresentationFormSheet在橫向模式下的iPad
- 14. iPhone/iPad的橫向方向和UIAlertView
- 15. 僅適用於ipad應用程序的橫向視圖(as3)
- 16. 在iPad中鎖定橫向模式
- 17. 而在橫向模式在iPad上
- 18. UIImagePickerController只從橫向選擇iPhone/iPad應用程序
- 19. UIScrollView僅適用於橫向
- 20. UITabbar僅適用於橫向
- 21. 橫向模式下的iPhone UIDatePicker?
- 22. 網頁在橫向模式的iPhone
- 23. 如何旋轉OpenGL以適應iPhone橫向模式?
- 24. UIView動畫不適用於橫向模式
- 25. 只適用於iPad或iPhone的iOS通用應用程序文件
- 26. MKAnnotation setImage適用於iPhone,但不適用於iPad/iPhone 6+
- 27. 在橫向和縱向模式下啓動iPad應用程序
- 28. iPhone SDK:圖像捕捉橫向模式
- 29. iPhone - 適用於iPhone/iPad的矢量格式
- 30. Ipad以肖像模式居中,在橫向模式下工作
謝謝。這真的很有幫助。 – Tirth 2010-10-15 06:52:39
總是忘記shouldAutorotateToInterfaceOrientation步驟,沒有你的整個UI出現橫向... – 2011-09-01 08:48:52