2013-05-21 67 views
1

所有人。我有兩個意見。第一個視圖僅支持橫向,第二個視圖支持所有的方向。但是,當第二個視圖是縱向並按下一個按鈕時,它將跳轉到第一個縱向,這意味着橫向。未能從縱向視圖跳轉到橫向視圖

我在第一個ViewController中添加了以下兩個方法。

- (BOOL)shouldAutorotate 
{ 
     return YES; 
} 

-(NSUInteger)supportedInterfaceOrientations 
{ 
    return UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight; 
} 

不知有沒有人能幫助我,因爲這個問題困擾了我很久。 感謝轉發!

+0

+1,希望它可以幫助你在你的聲譽。 :) – mAc

回答

0

我不知道我是否有ü正確與否。直到我得到的是,你有2個viewControllers,第一個viewController只支持景觀而第二個viewController支持所有的方向。但是你在維護這個問題上有問題。檢查你是否已經在你的代碼中實現了這一點,如果你仍然發現任何問題,做回恢復,如果它解決善意接受答案並投票了): -

1)你的第一個viewController應該有這樣的: - //爲iOS 6

-(BOOL)shouldAutorotate{ 
    return YES; 
} 

-(NSUInteger)supportedInterfaceOrientations{ 
    return UIInterfaceOrientationMaskLandscape; 
} 

爲< iOS 6的

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    return (interfaceOrientation == UIInterfaceOrientationLandscapeRight || interfaceOrientation == UIInterfaceOrientationLandscapeLeft); 

} 

2)你的第二個的viewController應該有這樣的: - 爲iOS 6

-(BOOL)shouldAutorotate{ 
    return YES; 
} 

-(NSUInteger)supportedInterfaceOrientations{ 
    return UIInterfaceOrientationMaskPortrait; 
} 

爲< iOS6的

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    return (interfaceOrientation == UIInterfaceOrientationPortrait); 
} 
+0

我試過了你的方法,但不幸的是它沒有工作。當我從第二個視圖縱向跳回到第一個視圖時,該設備是縱向的,而視圖是橫向的... – Calios

+0

我認爲你必須在縱向模式下有第一個視圖元素。你是否。?? – mAc

+0

給我你的電子郵件ID我已根據你的要求爲你製作了一個應用程序。是的,請接受我的回答,並請投票。 – mAc

0

我從來沒有在應用程序中測試這一點,但嘗試使用:

[[UIDevice currentDevice] setOrientation:UIDeviceOrientationPortrait]; 
+0

它警告我:'UIDevice'可能不會響應'setOrientation'...我試圖修復它到[UIDevice currentDevice] .orientation = UIDeviceOrientationLandscapeLeft;我得到了「賦值給只讀屬性」的錯誤.... – Calios

+0

您正在開發的iOS是什麼? – Mutawe

+0

iPad應用程序。自轉問題困擾了我很長一段時間,我近乎爲此而瘋狂...... – Calios

相關問題