2013-01-18 94 views
0

我使用故事板。在每個視圖CONTROLER我想旋轉包括我這個方法是這樣的:iOS 5.0 Modal View不旋轉(故事板)

- (BOOL)shouldAutorotateToInterfaceOrientation: 
(UIInterfaceOrientation)toInterfaceOrientation { 
    return YES; 
} 

在iOS 6中它旋轉就好在我的故事板我有橫向和縱向的正確意見。

在iOS 5父視圖控制器旋轉,但模式不旋轉,而他們在屏幕上,他們只旋轉之前,他們在屏幕上,但從來沒有在期間。所以當用戶改變方向時,它仍然是一樣的。父母在屏幕上將會改變,但是模態會採取父母的方向,但不會在屏幕上改變。如何讓我的模態視圖像iOS 6一樣在屏幕上旋轉。模態視圖是通過故事板創建的。

編輯*

當我做酥料餅的模式,模式不旋轉。我怎樣才能解決這個問題?

回答

1

旋轉在iOS5和iOS6中處理方式不同。我使用下面的代碼來支持這兩個版本。

// iOS5 
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    return YES; 
} 

// iOS6 
- (NSUInteger)supportedInterfaceOrientations 
{ 
    return UIInterfaceOrientationMaskAll; 
} 

- (BOOL)shouldAutorotate 
{ 
    return YES; 
} 

shouldAutorotateToInterfaceOrientation:已在iOS6中棄用。你可以在這裏閱讀:http://developer.apple.com/library/ios/#documentation/uikit/reference/UIViewController_Class/DeprecationAppendix/AppendixADeprecatedAPI.html#//apple_ref/occ/instm/UIViewController/shouldAutorotateToInterfaceOrientation

+0

這很有趣,因爲它可以在iOS6上正常工作,稍後我會處理該棄用。但我確實使用 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return YES; } 對於iOS 5,但問題是,它不是在模態視圖上旋轉。 – user1837396

+0

對不起,我沒有正確閱讀這個問題哈哈。這是代碼而不是模態viewController和viewController呈現模式? –

+0

用戶在iOS 5 iPad上啓動應用程序。在第一個屏幕上旋轉時,它會自動旋轉。 當他們點擊一個按鈕時,下一個視圖將以模態方式呈現,並且將以任意方向顯示第一個視圖。 當用戶更改方向時,當模型視圖向上時,屏幕不會改變方向,直到模態視圖已關閉。 – user1837396