shouldAutorotateToInterfaceOrientation但没有任何反应

时间:2011-10-07 22:38:45

标签: iphone ios xcode ipad

我们的应用被拒绝,因为该应用不会以颠倒方向旋转。

所以我们有一个tabbar App,将此代码添加到所有标签...

shouldAutorotateToInterfaceOrientation

毫无意义,将此代码添加到Appdelegate没有帮助,我们做错了什么?

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

2 个答案:

答案 0 :(得分:2)

UITabbarcontroller是UIViewcontroller的子类。为了解决您的问题,只需为UITabbarcontroller实现子类或添加类别:

@interface UITabBarController (rotation)
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation;
@end

@implementation UITabBarController (rotation)
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
     return YES;
}
@end

如果您想使标签栏仅旋转为纵向和颠倒,请使用以下代码

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait ||
            interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown);
}

答案 1 :(得分:0)

确保每个 UIViewController实现

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