2013-03-21 18 views
0

我的iPad應用程序設置爲支持兩種風景方向(左側和右側)。當我在6.0或6.1模擬器中運行它時,它的行爲如預期。但在5.1中,它被鎖定到肖像(向上或向下,我無法說出),並且在模擬器旋轉時不會重新定向。如何支持iOS 5和iOS 6中的方向,而無需修改每個視圖控制器文件?

編輯:這已被標記爲重複這個問題:Supporting both iOS 6 and iOS 5 autorotation

我改變要問的問題,怎麼可以這樣,而無需添加此功能完成的:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    // Return YES for supported orientations 
    return UIInterfaceOrientationIsLandscape(interfaceOrientation); 
} 

要每個視圖控制器?

+0

這是因爲定向的方式被處理是iOS5的和iOS6的不同。我發現這個答案有幫助:http://stackoverflow.com/a/13800907/620197 – 2013-03-21 03:15:47

+0

返回YES在shouldAutorotateToInterfaceOrientation – 2013-03-21 03:18:46

回答

3

您需要重寫下面的方法,這樣的支持方向按在IOS 5.1和早期版本的要求......

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    return UIInterfaceOrientationIsLandscape(interfaceOrientation); 
} 
+1

謝謝Bhanu。我已經改變了這個問題,因爲它是一個騙局。 – guptron 2013-03-21 14:48:04

+0

Bhanu Prakash +1,有沒有人知道iOS 7兼容? – 2014-03-03 04:55:52

相關問題