我目前正在将screcorder库集成到iOS项目中,并且在screcorder上设置videoOrientation属性时遇到了一个问题。在短时间内预览视频似乎闪烁。
我理解这是由于screcorder设置了正确的方向。由于我不希望在更改设备方向时自动调整方向,因此每次按下录制按钮时都会在screcorder上设置方向。
我无法在viewDidLoad上设置方向,因为只能以横向方向录制视频。
- (IBAction)record:(id)sender
{
if (!_orientationIsSet) {
UIInterfaceOrientation interfaceOrientation = (UIInterfaceOrientation) [[UIDevice currentDevice] orientation];
switch(interfaceOrientation)
{
case UIDeviceOrientationPortrait:
_recorder.videoOrientation = AVCaptureVideoOrientationLandscapeLeft;
break;
case UIDeviceOrientationPortraitUpsideDown:
_recorder.videoOrientation = AVCaptureVideoOrientationLandscapeRight;
break;
case UIDeviceOrientationLandscapeLeft:
_recorder.videoOrientation = AVCaptureVideoOrientationLandscapeRight;
break;
case UIDeviceOrientationLandscapeRight:
_recorder.videoOrientation = AVCaptureVideoOrientationLandscapeLeft;
break;
default:
break;
};
_orientationIsSet = YES;
}
[_recorder record];
}
感谢任何提示!