0
我需要帶有圖像覆蓋層(未記錄)的水平視頻相機輸入。帶覆蓋層的水平相機
問題在於,當處於活動狀態時,相機視圖旋轉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;
}
當相機在水平模式中,它是像渲染視圖不同步的。出現遮罩,但實際攝像機視圖不正確。當我將相機向右移動時,它會下降,就好像旋轉方向一樣。 在iOS 9.2.1中使用iPhone 6。