2013-09-24 61 views
0

我想我幾乎讀過關於此主題的每篇文章。所以在你閱讀之前不要殺死這個問題。此問題適用於iOS 7上的XCode 5UIInterfaceOrientation景觀與Xcode 5中的肖像問題

我有一個支持橫向和縱向模式的應用程序。在我的項目中檢查部署信息所有方向。

當應用程序啓動我告訴

  • v1ViewController當用戶點擊一個按鈕,就帶他們去

    • v3ViewController((總是應該打開在橫向模式下)

    這總是應該以縱向模式打開)

我遇到的問題是,當應用程序啓動時,我在肖像模式下拿着iphone它顯示此。

enter image description here

如果我在等維護橫向模式的iphone就說明這一點。

enter image description here

我怎麼能強迫我v1ViewController總是顯示橫向模式?

這是我現在的代碼。

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight) 
    { 
     return YES; 
    } 
    else 
    { 
     return NO; 
    } 

} 

但是,如果我加這個,然後視圖總是打開像我顯示的第一張圖片和旋轉沒有效果。

- (BOOL)shouldAutorotate 
{ 

    UIInterfaceOrientation interfaceOrientation = [[UIApplication sharedApplication] statusBarOrientation]; 

    NSLog(@"interfaceOrientation: %d ...", interfaceOrientation); 



    if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft) 
    { 
     return YES; 
    } 
    else if (interfaceOrientation == UIInterfaceOrientationLandscapeRight) 
    { 
     return YES; 
    } 
    else 
    { 
     return NO; 
    } 

} 

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation 
{ 
    return UIInterfaceOrientationLandscapeLeft; 
} 

-(NSUInteger)supportedInterfaceOrientations 
{ 
    return UIInterfaceOrientationLandscapeLeft | UIInterfaceOrientationLandscapeRight; 
} 
+0

可能是這個鏈接可以幫助你http://stackoverflow.com/questions/12640870/ios-6-force-device-orientation-to-landscape/13360116#13360116 如果你仍然面臨的問題然後讓我知道 –

+0

@AuuragSoni謝謝你指出我在正確的方向。 –

+0

這樣你的問題就解決了嗎? –

回答

4

對於任何對我如何工作感興趣的人,這就是我所做的。

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

-(NSUInteger)supportedInterfaceOrientations 
{ 

    return UIInterfaceOrientationMaskLandscape; 
} 

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation 
{ 
    return UIInterfaceOrientationLandscapeLeft; 
} 
+0

你應該接受你自己的答案。 – dccarmo