我有一个iPhone应用程序,其中RootViewController
实例以横向模式开始。它支持相机,因此它将更改为纵向模式以拍摄照片。完成后,它将返回RootViewController
实例,但方向不会更改为横向。我希望这会自动切换到横向。
我尝试添加
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight animated:NO]
<{1>} viewWillAppear
方法RootViewController
或viewWillDisapper
CameraViewController
但方向不会改变。如何以编程方式更改方向?
答案 0 :(得分:0)
尝试在控制器中实现以下方法。
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
if((interfaceOrientation == UIInterfaceOrientationLandscapeLeft) || (interfaceOrientation == UIInterfaceOrientationLandscapeRight))
return YES;
return NO;
}
希望它有所帮助。