Xcode无法自动从肖像变回横向

时间:2011-06-24 07:42:38

标签: iphone objective-c cocoa-touch uiinterfaceorientation

我有一个iPhone应用程序,其中RootViewController实例以横向模式开始。它支持相机,因此它将更改为纵向模式以拍摄照片。完成后,它将返回RootViewController实例,但方向不会更改为横向。我希望这会自动切换到横向。

我尝试添加

[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight animated:NO]
<{1>} viewWillAppear方法RootViewControllerviewWillDisapper CameraViewController但方向不会改变。如何以编程方式更改方向?

1 个答案:

答案 0 :(得分:0)

尝试在控制器中实现以下方法。

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

希望它有所帮助。