2012-09-23 52 views
2

在我的應用程序中,我一直在使用現在已棄用的shouldAutoRotateToFace方法。現在,當使用iOS 6模擬器時,我的所有子視圖都會在設備處於橫向時旋轉到縱向。有沒有人有任何想法可能會導致這種情況?我已經嘗試替換應該使用supportedOrientations方法在我的主視圖控制器中進行自動旋轉(或者您現在應該使用的方法)。在iOS 6視圖控制器的旋轉不正確

回答

7

如果您可以登錄到蘋果開發論壇,check out this thread

基本上,這是幫助我的資料:


1.我必須設置在window.rootViewController = mainViewController

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 

2.對於視圖控制器,其中

- (BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation 

沒有只是返回YES,我不得不添加

- (NSUInteger)supportedInterfaceOrientations 

返回的值相同

新增

- (BOOL)shouldAutorotate { 
    return YES; 
} 

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

到mainViewController 。米

4.新增

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window { 
    return (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft | 
      UIInterfaceOrientationMaskLandscapeRight | UIInterfaceOrientationMaskPortraitUpsideDown); 
} 

到appDelegate.m(我相信這是可選的,對於他們沒有在應用程序的Info.plist文件中指定的情況下設置的默認值,或在各個視圖控制器)



因爲我希望我的代碼向後兼容回到3.0我沒有使用所有取向口罩,因爲我需要使用的XCode 4.3

+0

這看起來正是我需要編譯 - 我嘗試了所有的這些,但分開,因爲我以爲他們是個性化解決方案。 –

+0

到目前爲止,這已經成功了。非常感謝! –

+2

「我必須在應用程序的委託中設置window.rootViewController = mainViewController」對我來說是什麼。 –

相關問題