带覆盖的水平相机
Horizontal Camera with Overlay
我需要一个带有图像覆盖(未记录)的水平摄像机输入。
问题是,当处于活动状态时,即使其他所有内容都正确水平定向,相机视图也会旋转 90 度。
UIImagePicker 不能做水平方向,我在使用带有图形覆盖的 AVCapture 时遇到了问题。所以,我使用自定义视图并旋转它。
相机初始化
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;
}
当相机处于水平模式时,就像渲染视图不同步一样。遮罩出现,但实际相机视图不正确。当我将相机向右移动时,它会下降,就好像方向旋转了一样。
使用 iPhone 6 和 iOS 9.2.1。
如果它对任何人有帮助,要制作水平 UIImagePicker ,您必须创建一个完全自定义的视图。
我需要一个带有图像覆盖(未记录)的水平摄像机输入。
问题是,当处于活动状态时,即使其他所有内容都正确水平定向,相机视图也会旋转 90 度。
UIImagePicker 不能做水平方向,我在使用带有图形覆盖的 AVCapture 时遇到了问题。所以,我使用自定义视图并旋转它。
相机初始化
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;
}
当相机处于水平模式时,就像渲染视图不同步一样。遮罩出现,但实际相机视图不正确。当我将相机向右移动时,它会下降,就好像方向旋转了一样。 使用 iPhone 6 和 iOS 9.2.1。
如果它对任何人有帮助,要制作水平 UIImagePicker ,您必须创建一个完全自定义的视图。