支持方向IOS

时间:2012-03-08 22:11:08

标签: iphone objective-c ios rotation

您好我想在我的应用程序中上下支持肖像,主页按钮我该怎么做?

我转到我的项目设置,检查这两个enter image description here

我添加下面的代码

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

我也试过

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait || interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown);
}

但似乎没有工作

任何帮助

1 个答案:

答案 0 :(得分:2)

试试这个

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{  
    if((interfaceOrientation == UIInterfaceOrientationPortrait) || (interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)){
        return YES;
   }
   return NO;
}

如果它仍然不起作用,你可以尝试这个(只是为了测试)

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

如果这不起作用,要么您没有弄乱右视图控制器,要么父/根视图控制器已禁用旋转(在rootVC的shouldAutoRotate方法中返回NO)