|
@@ -158,41 +158,43 @@
|
|
|
// [self presentViewController:imgPicker animated:YES completion:nil];
|
|
// [self presentViewController:imgPicker animated:YES completion:nil];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+ CGFloat w = CGRectGetWidth(self.view.frame);
|
|
|
|
|
+ CGFloat h = CGRectGetHeight(self.view.frame);
|
|
|
// 自定义相机控制视图
|
|
// 自定义相机控制视图
|
|
|
UIImagePickerController *imgPicker = [[UIImagePickerController alloc] init];
|
|
UIImagePickerController *imgPicker = [[UIImagePickerController alloc] init];
|
|
|
imgPicker.delegate = self;
|
|
imgPicker.delegate = self;
|
|
|
imgPicker.sourceType = UIImagePickerControllerSourceTypeCamera;
|
|
imgPicker.sourceType = UIImagePickerControllerSourceTypeCamera;
|
|
|
imgPicker.allowsEditing = NO;
|
|
imgPicker.allowsEditing = NO;
|
|
|
imgPicker.showsCameraControls = NO;
|
|
imgPicker.showsCameraControls = NO;
|
|
|
- UIView* overlay = [[UIView alloc]initWithFrame:CGRectMake(0, self.view.frame.size.height - 150 , self.view.frame.size.width, 150)];
|
|
|
|
|
|
|
+ UIView* overlay = [[UIView alloc]initWithFrame:CGRectMake(0, h - 150 , w, 150)];
|
|
|
|
|
|
|
|
// Cancel
|
|
// Cancel
|
|
|
UIButton *cancelBtn = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
UIButton *cancelBtn = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
|
- cancelBtn.frame = CGRectMake(10, 10, 60, 40);
|
|
|
|
|
|
|
+ cancelBtn.frame = CGRectMake(20, (150 - 40) * 0.5, 60, 40);
|
|
|
[cancelBtn setTitle:@"cancel" forState:UIControlStateNormal];
|
|
[cancelBtn setTitle:@"cancel" forState:UIControlStateNormal];
|
|
|
[cancelBtn addTarget:self action:@selector(cancelCameraClick:) forControlEvents:UIControlEventTouchUpInside];
|
|
[cancelBtn addTarget:self action:@selector(cancelCameraClick:) forControlEvents:UIControlEventTouchUpInside];
|
|
|
[overlay addSubview:cancelBtn];
|
|
[overlay addSubview:cancelBtn];
|
|
|
|
|
|
|
|
// Take
|
|
// Take
|
|
|
UIButton *takeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
UIButton *takeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
|
- takeBtn.frame = CGRectMake(80, 10, 60, 40);
|
|
|
|
|
|
|
+ takeBtn.frame = CGRectMake((w - 60) * 0.5, (150 - 40) * 0.5, 60, 40);
|
|
|
[takeBtn setTitle:@"take" forState:UIControlStateNormal];
|
|
[takeBtn setTitle:@"take" forState:UIControlStateNormal];
|
|
|
[takeBtn addTarget:self action:@selector(takePhotoClick:) forControlEvents:UIControlEventTouchUpInside];
|
|
[takeBtn addTarget:self action:@selector(takePhotoClick:) forControlEvents:UIControlEventTouchUpInside];
|
|
|
[overlay addSubview:takeBtn];
|
|
[overlay addSubview:takeBtn];
|
|
|
|
|
|
|
|
// flash
|
|
// flash
|
|
|
UIButton *flashBtn = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
UIButton *flashBtn = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
|
- flashBtn.frame = CGRectMake(150, 10, 60, 40);
|
|
|
|
|
|
|
+ flashBtn.frame = CGRectMake(w - 80, (150 - 40) * 0.5, 60, 40);
|
|
|
[flashBtn setTitle:@"Auto" forState:UIControlStateNormal];
|
|
[flashBtn setTitle:@"Auto" forState:UIControlStateNormal];
|
|
|
[flashBtn addTarget:self action:@selector(flashBtnClick:) forControlEvents:UIControlEventTouchUpInside];
|
|
[flashBtn addTarget:self action:@selector(flashBtnClick:) forControlEvents:UIControlEventTouchUpInside];
|
|
|
[overlay addSubview:flashBtn];
|
|
[overlay addSubview:flashBtn];
|
|
|
|
|
|
|
|
- // camera
|
|
|
|
|
- UIButton *cameraChangeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
|
|
|
- cameraChangeBtn.frame = CGRectMake(220, 10, 60, 40);
|
|
|
|
|
- [cameraChangeBtn setTitle:@"change" forState:UIControlStateNormal];
|
|
|
|
|
- [cameraChangeBtn addTarget:self action:@selector(cameraChangeClick:) forControlEvents:UIControlEventTouchUpInside];
|
|
|
|
|
- [overlay addSubview:cameraChangeBtn];
|
|
|
|
|
|
|
+// // camera
|
|
|
|
|
+// UIButton *cameraChangeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
|
|
|
+// cameraChangeBtn.frame = CGRectMake(220, 10, 60, 40);
|
|
|
|
|
+// [cameraChangeBtn setTitle:@"change" forState:UIControlStateNormal];
|
|
|
|
|
+// [cameraChangeBtn addTarget:self action:@selector(cameraChangeClick:) forControlEvents:UIControlEventTouchUpInside];
|
|
|
|
|
+// [overlay addSubview:cameraChangeBtn];
|
|
|
|
|
|
|
|
|
|
|
|
|
// 相机属性设置得在设置SourceType后设置
|
|
// 相机属性设置得在设置SourceType后设置
|
|
@@ -414,22 +416,27 @@
|
|
|
TakePhotoPreviewController *preVC = (TakePhotoPreviewController *)[self viewControllerInStoryboard:@"Mode" withId:@"TakePhotoPreviewController"];
|
|
TakePhotoPreviewController *preVC = (TakePhotoPreviewController *)[self viewControllerInStoryboard:@"Mode" withId:@"TakePhotoPreviewController"];
|
|
|
preVC.photoHandler = ^(UIImage *img){
|
|
preVC.photoHandler = ^(UIImage *img){
|
|
|
if (img) {
|
|
if (img) {
|
|
|
- NSString *path = [weakself saveImage:img];
|
|
|
|
|
- if (path) {// 保存成功
|
|
|
|
|
- [weakself receiveImage:img];
|
|
|
|
|
- NSString *md5 = [RAUtils md5WithFile:path];
|
|
|
|
|
- NSMutableDictionary *photoDic = @{
|
|
|
|
|
- @"photo" : img,
|
|
|
|
|
- @"check" : @(NO),
|
|
|
|
|
- @"file" : [path lastPathComponent],
|
|
|
|
|
- @"md5" : md5,
|
|
|
|
|
- @"path" : path
|
|
|
|
|
- }.mutableCopy;
|
|
|
|
|
- [weakself.photos addObject:photoDic];
|
|
|
|
|
- weakself.photoCount++;
|
|
|
|
|
- } else {
|
|
|
|
|
- [RAUtils message_alert:@"Save photo failed" title:@"Warning" controller:weakself];
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ dispatch_async(dispatch_get_global_queue(0, 0), ^{
|
|
|
|
|
+ NSString *path = [weakself saveImage:img];
|
|
|
|
|
+ dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
|
+ if (path) {// 保存成功
|
|
|
|
|
+ [weakself receiveImage:img];
|
|
|
|
|
+ NSString *md5 = [RAUtils md5WithFile:path];
|
|
|
|
|
+ NSMutableDictionary *photoDic = @{
|
|
|
|
|
+ @"photo" : img,
|
|
|
|
|
+ @"check" : @(NO),
|
|
|
|
|
+ @"file" : [path lastPathComponent],
|
|
|
|
|
+ @"md5" : md5,
|
|
|
|
|
+ @"path" : path
|
|
|
|
|
+ }.mutableCopy;
|
|
|
|
|
+ [weakself.photos addObject:photoDic];
|
|
|
|
|
+ weakself.photoCount++;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ [RAUtils message_alert:@"Save photo failed" title:@"Warning" controller:weakself];
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ });
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
preVC.preImage = image;
|
|
preVC.preImage = image;
|