在UIImagePickerController中强制横向方向

Fer*_*ndo 11 xcode objective-c orientation uiimagepickercontroller ios

我是iOS开发的新手,我正在开发我的第一个应用程序.(很抱歉,如果我问一个新手问题)

我的应用程序都是纵向的,除了我正在使用UIImagePickerController来拍照在应用程序中使用的地方,我正在做的是:

UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.mediaTypes = [NSArray arrayWithObject:(NSString *)kUTTypeImage];
picker.allowsEditing = NO;
[self presentModalViewController:picker animated:YES];
Run Code Online (Sandbox Code Playgroud)

由于我的应用程序是在Portrait中,我需要在UIImagePickerController中创建一些横向中.如果我尝试使用:

[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationLandscapeRight];
Run Code Online (Sandbox Code Playgroud)

似乎我无法使用,因为我的Xcode在这一行中识别为错误(可能是因为Xcode的版本,我不确定).而且我不确定,但似乎如果我正在为iOS 5.1开发我也需要为iOS 6.0实现一些东西,它是否正确?

有人可以帮助我理解制作这个UIImagePickerController需要什么,只有应用程序中的这个视图控制器,在横向工作,并在iOS 5.1和6中工作?

问候

Gle*_*ett 14

根据UIImagePickerController类参考

重要说明:UIImagePickerController该类仅支持纵向模式.此类旨在按原样使用,不支持子类化.此类的视图层次结构是私有的,不得修改,但有一个例外.您可以将自定义视图分配给cameraOverlayView属性,并使用该视图显示其他信息或管理相机界面与代码之间的交互.

所以看起来强制横向模式不受支持和阻止,除非你通过用自定义替换默认控件来实现cameraOverlayView.