有沒有一種方法可以讓我的應用在橫向模式下可見?我設法將應用程序的方向默認爲橫向,但是在iPad模擬器中,當我執行Command-> Arrow時,應用程序將旋轉爲縱向。我已經刪除了在「支持的界面方向」下的plist列表中的兩個肖像條目,但是這似乎沒有改變任何東西。在iPhone SDK中移除應用的縱向取向功能
任何想法?
有沒有一種方法可以讓我的應用在橫向模式下可見?我設法將應用程序的方向默認爲橫向,但是在iPad模擬器中,當我執行Command-> Arrow時,應用程序將旋轉爲縱向。我已經刪除了在「支持的界面方向」下的plist列表中的兩個肖像條目,但是這似乎沒有改變任何東西。在iPhone SDK中移除應用的縱向取向功能
任何想法?
在您的視圖控制器,有此委託方法:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return ((interfaceOrientation == UIInterfaceOrientationLandscapeLeft) ||
(interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
完美。我知道我以前看過這行代碼,只是忘了它。 – 2010-07-05 00:13:12
這已過時;此方法從iOS 6開始已棄用。 – 2016-01-22 19:32:19
做一個項目找到「自動旋轉」,並編輯你會找到相應的方法。
其實這是
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft) ||
(interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
事情隨着更新而改變秒。目前,您只需添加以下方法:
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscape;
}
只會允許橫向。打開你喜歡的電話,它只會停留在左或右景觀。玩得開心:)
你是什麼意思「旋轉到肖像」?你意識到沒有什麼可以阻止用戶在物理上旋轉設備,對吧? – 2010-07-04 23:40:46
是的,但某些應用程序能夠將其方向鎖定爲橫向,即使設備面向縱向。 – 2010-07-05 00:10:54