我是 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/