我有一個應用程序與我想檢測界面方向的一個tabbar。應用程序不改變方向
我已經在info.plist中設置了支持的方向。 這是我的主界面聲明:
@interface MyAppDelegate : NSObject <UIApplicationDelegate, UITabBarControllerDelegate> {
...
}
這是MyAppDelegate執行:
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft)
return NO;
if (interfaceOrientation == UIInterfaceOrientationLandscapeRight)
return YES;
if (interfaceOrientation == UIInterfaceOrientationPortrait)
return YES;
if (interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)
return NO;
}
,並在我試圖檢測取向變化必要的看法,我打電話這些方法:
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration;
和
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation;
我已經在這些方法中設置NSLog打印,他們都沒有註冊任何更改。甚至沒有在shouldAutorotateToInterfaceOrientation方法中。
任何人都可以幫我嗎?我在做什麼錯了? 任何幫助將不勝感激。
謝謝你,奧雷Begemann。應該在所有視圖控制器中實現shouldAutorotateToInterfaceOrientation方法,以使方向工作。我得到了它的工作。但現在問題是所有的選項卡都在旋轉(我有3個),我只需要旋轉第二個。 如果你幫我這個,你有啤酒:) 無論如何,再次感謝。幫助我很多! – Cornholio 2011-02-15 09:42:39