2011-03-26 61 views
1

我有一個景觀應用程序,我想旋轉180度,如果設備翻轉。然而,在我的主視圖控制器中,shouldAutorotateToInterfaceOrientation根本沒有被調用。爲什麼會這樣?shouldAutorotateToInterfaceOrientation沒有被調用

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 
    // Return YES for supported orientations 
    NSLog(@"ROTATE? %d", interfaceOrientation); //this never gets logged 
    return (interfaceOrientation == UIInterfaceOrientationLandscapeRight || interfaceOrientation == UIInterfaceOrientationLandscapeLeft); 
} 

編輯:在應用程序的委託:

- (void)applicationDidFinishLaunching:(UIApplication *)application {  

    [window addSubview:topViewController.view]; 
    [window makeKeyAndVisible]; 

} 
+3

您是否在窗口中添加了多個控制器視圖? 請參閱:http://developer.apple.com/library/ios/#qa/qa1688/_index.html (技術問答QA1688 爲什麼我的UIViewController不能隨設備一起旋轉?) – Krumelur 2011-03-26 00:12:44

+0

不,我將編輯顯示應用程序委託的帖子。 – sol 2011-03-26 00:20:34

+1

您是否編輯過Info.plist文件以顯示它支持這兩種方向? – ughoavgfhw 2011-03-26 01:34:35

回答

0

對不起,我是編輯錯誤的視圖控制器文件(iphone ipad的VS)。上面的代碼工作。 BTW @ughoavgfhw,編輯info.plist並不是必要的。

相關問題