ios - 在 UIImagePickerController 中强制横向

标签 ios objective-c xcode orientation uiimagepickercontroller

我是 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];

由于我的应用是Portrait,我需要对UIImagePickerController做一些仅横向的操作。如果我尝试使用:

[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationLandscapeRight];

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

谁能帮我理解制作这个 UIImagePickerController 以及应用程序中只有这个 View Controller 需要什么才能在横向模式下工作并在 iOS 5.1 和 6 中工作?

问候

最佳答案

根据 UIImagePickerController Class Reference

Important: The UIImagePickerController class supports portrait mode only. This class is intended to be used as-is and does not support subclassing. The view hierarchy for this class is private and must not be modified, with one exception. You can assign a custom view to the cameraOverlayView property and use that view to present additional information or manage the interactions between the camera interface and your code.

因此看起来强制横屏模式不受支持且不鼓励,除非您通过将默认控件替换为自定义 cameraOverlayView 来这样做。

关于ios - 在 UIImagePickerController 中强制横向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14618546/

相关文章:

ios - Swift 协议(protocol)作为从 Objective C 类调用的初始化参数

ios - 如何获取通过 Storyboard添加到 View 的控件的句柄?

ios - 首选语言更改后如何恢复应用程序的状态?

iphone - 如何将日期字符串解析为 iOS 中的 NSDate 对象?

ios - iphone/iPad 中的方向问题

ios - 调用中有额外的参数“错误”。 Swift 2.0中的编译错误

ios - 天球中恒星的OpenGL可视化

iphone - 如何在 iOS 上执行 DNS 查询

ios - 如何使用 PKAddPaymentPassViewController 将卡添加到 Apple Pay?

iOS - Facebook SDK - SSO - 没有登录对话框的登录