我需要一个带有图像叠加的水平摄像机输入(未记录)。
问题在于,当激活时,即使其他所有内容都水平方向正确,摄像机视图也会旋转90度。
UIImagePicker无法进行水平方向,而且我在使用带图形叠加的AVCapture时遇到了麻烦。所以,我使用自定义视图并旋转它。
Camera Init
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
{
//Custom View Instead of UIImagePicker
_video_picker = [[VCImagePickerController alloc] init];
_video_picker.delegate = self;
_video_picker.allowsEditing = YES;
_video_picker.sourceType = UIImagePickerControllerSourceTypeCamera;
_video_picker.cameraDevice = UIImagePickerControllerCameraDeviceFront;
_video_picker.mediaTypes = [[NSArray alloc] initWithObjects: (NSString *) kUTTypeMovie, nil];
_video_picker.showsCameraControls = NO;
//Set the orientation
_video_picker.modalPresentationStyle = UIModalPresentationCurrentContext;
//Display overlay graphics
_video_picker.cameraOverlayView = _overVW ;
[self.navigationController presentViewController:_video_picker animated:NO completion:nil];
然后在自定义VCImagePickerController视图中,设置掩码:
- (BOOL)shouldAutorotate
{
return YES;
}
-(UIInterfaceOrientationMask)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscape;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationLandscapeRight;
}
当相机处于水平模式时,就像渲染的视图不同步一样。出现掩码,但实际的摄像机视图不正确。当我将相机向右移动时,它会向下移动,就像方向旋转一样。 使用带有iOS 9.2.1的iPhone 6。
答案 0 :(得分:0)
如果它可以帮助任何人创建一个水平的UIImagePicker,你必须创建一个完全自定义的视图。