From bf248c7fc450a183fec3d2832780a5beb30eee5c Mon Sep 17 00:00:00 2001 From: zher52 Date: Mon, 11 Oct 2021 21:58:33 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90ios=E7=AB=AF=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E5=A4=84=E7=90=86,ios=E7=AB=AF=E5=9F=BA=E6=9C=AC?= =?UTF-8?q?=E5=8F=AF=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ios/SGRecord/SGRecordManager.h | 1 + src/ios/SGRecord/SGRecordManager.m | 16 ++++++++-------- src/ios/SGRecord/SGRecordViewController.m | 6 +++--- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/ios/SGRecord/SGRecordManager.h b/src/ios/SGRecord/SGRecordManager.h index e16baf9..8292baa 100644 --- a/src/ios/SGRecord/SGRecordManager.h +++ b/src/ios/SGRecord/SGRecordManager.h @@ -35,6 +35,7 @@ */ - (AVCaptureVideoPreviewLayer *)previewLayer; ++ (instancetype) createFromOption:(SGRecordOptions*)options; /** 拍照 diff --git a/src/ios/SGRecord/SGRecordManager.m b/src/ios/SGRecord/SGRecordManager.m index 5ab0a70..e30adc3 100644 --- a/src/ios/SGRecord/SGRecordManager.m +++ b/src/ios/SGRecord/SGRecordManager.m @@ -44,12 +44,12 @@ typedef void(^PropertyChangeBlock)(AVCaptureDevice *captureDevice); @end @implementation SGRecordManager -- (instancetype)init { - self = [super init]; - if (self) { - self.maxRecordTime = self.options.duration.intValue; - } - return self; + ++ (instancetype) createFromOption:(SGRecordOptions*)options{ + SGRecordManager *manager =[[SGRecordManager alloc] init]; + manager.options = options; + manager.maxRecordTime = manager.options.duration.floatValue; + return manager; } #pragma mark - 操作方法 @@ -198,8 +198,8 @@ typedef void(^PropertyChangeBlock)(AVCaptureDevice *captureDevice); //添加视频输出 if ([_recordSession canAddOutput:self.videoOutput]) { [_recordSession addOutput:self.videoOutput]; - _cx = self.options.width; - _cy = self.options.height; + _cx = self.options.width.intValue; + _cy = self.options.height.intValue; } //添加音频输出 if ([_recordSession canAddOutput:self.audioOutput]) { diff --git a/src/ios/SGRecord/SGRecordViewController.m b/src/ios/SGRecord/SGRecordViewController.m index 16175f8..68633c4 100644 --- a/src/ios/SGRecord/SGRecordViewController.m +++ b/src/ios/SGRecord/SGRecordViewController.m @@ -16,7 +16,8 @@ #import "UIButton+Convenience.h" #import "SGRecordOptions.h" #import "SGMotionManager.h" - +#define WEAKSELF __weak typeof(self) weakSelf = self; +#define STRONGSELF __strong typeof(weakSelf) strongSelf = weakSelf; #define TIMER_INTERVAL 0.5 //定时器时间间隔 #define RECORD_TIME 0.5 //开始录制视频的时间 @interface SGRecordViewController () @@ -160,8 +161,7 @@ #pragma mark - set、get方法 - (SGRecordManager *)recordManger { if (!_recordManger) { - _recordManger = [[SGRecordManager alloc] init]; - _recordManger.options = self.options; + _recordManger = [SGRecordManager createFromOption: self.options]; _recordManger.delegate = self; } return _recordManger;