我有一个应用程序与我想检测界面方向的一个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