|
@@ -10,6 +10,9 @@
|
|
|
#import "ScannerViewController.h"
|
|
#import "ScannerViewController.h"
|
|
|
#import "PhotoListViewController.h"
|
|
#import "PhotoListViewController.h"
|
|
|
#import "UploadViewController.h"
|
|
#import "UploadViewController.h"
|
|
|
|
|
+#import <AVFoundation/AVFoundation.h>
|
|
|
|
|
+#import <AssetsLibrary/AssetsLibrary.h>
|
|
|
|
|
+
|
|
|
|
|
|
|
|
@interface BasicModeViewController ()<UITextFieldDelegate>
|
|
@interface BasicModeViewController ()<UITextFieldDelegate>
|
|
|
|
|
|
|
@@ -55,7 +58,8 @@
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
PhotoListViewController *photoListVC = (PhotoListViewController *)[self viewControllerInStoryboard:@"PhotoList" withId:@"PhotoListViewController"];
|
|
PhotoListViewController *photoListVC = (PhotoListViewController *)[self viewControllerInStoryboard:@"PhotoList" withId:@"PhotoListViewController"];
|
|
|
- photoListVC.photos = [self.photos mutableCopy];
|
|
|
|
|
|
|
+// photoListVC.photos = self.photos;
|
|
|
|
|
+ photoListVC.modeVC = self;
|
|
|
[self.navigationController pushViewController:photoListVC animated:YES];
|
|
[self.navigationController pushViewController:photoListVC animated:YES];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -78,32 +82,58 @@
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- (void)showCamera {
|
|
- (void)showCamera {
|
|
|
|
|
+ if (![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
|
|
|
|
|
+ [RAUtils message_alert:@"Camera is not available" title:@"Warning" controller:self];
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ //相机权限
|
|
|
|
|
+ AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];
|
|
|
|
|
+ if (authStatus ==AVAuthorizationStatusRestricted ||//此应用程序没有被授权访问的照片数据。可能是家长控制权限
|
|
|
|
|
+ authStatus ==AVAuthorizationStatusDenied) //用户已经明确否认了这一照片数据的应用程序访问
|
|
|
|
|
+ {
|
|
|
|
|
+ // 无权限 引导去开启
|
|
|
|
|
+ NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
|
|
|
|
|
+ if ([[UIApplication sharedApplication]canOpenURL:url]) {
|
|
|
|
|
+ [[UIApplication sharedApplication]openURL:url];// 打开权限后返回应用会重启
|
|
|
|
|
+ } else {
|
|
|
|
|
+ [RAUtils message_alert:@"RA Image need Authorization to use Camera" title:@"Warning" controller:self];
|
|
|
|
|
+ }
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
UIImagePickerController *imgPicker = [[UIImagePickerController alloc] init];
|
|
UIImagePickerController *imgPicker = [[UIImagePickerController alloc] init];
|
|
|
imgPicker.delegate = self;
|
|
imgPicker.delegate = self;
|
|
|
- // AVAuthorizationStatus status = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];
|
|
|
|
|
- // if (status != AVAuthorizationStatusAuthorized) {
|
|
|
|
|
- // // 未授权
|
|
|
|
|
- // [RAUtils message_alert:@"please allow app use camera" title:@"Warning" controller:weakself];
|
|
|
|
|
- // } else {
|
|
|
|
|
|
|
+
|
|
|
imgPicker.sourceType = UIImagePickerControllerSourceTypeCamera;
|
|
imgPicker.sourceType = UIImagePickerControllerSourceTypeCamera;
|
|
|
imgPicker.allowsEditing = YES;
|
|
imgPicker.allowsEditing = YES;
|
|
|
[self presentViewController:imgPicker animated:YES completion:nil];
|
|
[self presentViewController:imgPicker animated:YES completion:nil];
|
|
|
|
|
|
|
|
- // }
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- (void)showPhotoLibrary {
|
|
- (void)showPhotoLibrary {
|
|
|
|
|
+ if (![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) {
|
|
|
|
|
+ [RAUtils message_alert:@"Photo Library is not available" title:@"Warning" controller:self];
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ //相册权限
|
|
|
|
|
+ ALAuthorizationStatus author = [ALAssetsLibrary authorizationStatus];
|
|
|
|
|
+ if (author ==ALAuthorizationStatusRestricted || author ==ALAuthorizationStatusDenied){
|
|
|
|
|
+ //无权限 引导去开启
|
|
|
|
|
+ NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
|
|
|
|
|
+ if ([[UIApplication sharedApplication] canOpenURL:url]) {
|
|
|
|
|
+ [[UIApplication sharedApplication] openURL:url];
|
|
|
|
|
+ } else {
|
|
|
|
|
+ [RAUtils message_alert:@"RA Image need Authorization to use photo library" title:@"Warning" controller:self];
|
|
|
|
|
+ }
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
UIImagePickerController *imgPicker = [[UIImagePickerController alloc] init];
|
|
UIImagePickerController *imgPicker = [[UIImagePickerController alloc] init];
|
|
|
imgPicker.delegate = self;
|
|
imgPicker.delegate = self;
|
|
|
- // ALAuthorizationStatus author = [ALAssetsLibrary authorizationStatus];
|
|
|
|
|
- // if (author != ALAuthorizationStatusAuthorized) {
|
|
|
|
|
- // [RAUtils message_alert:@"please allow app visit photo library" title:@"Warning" controller:weakself];
|
|
|
|
|
- // } else {
|
|
|
|
|
imgPicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
|
|
imgPicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
|
|
|
imgPicker.allowsEditing = NO;
|
|
imgPicker.allowsEditing = NO;
|
|
|
[self presentViewController:imgPicker animated:YES completion:nil];
|
|
[self presentViewController:imgPicker animated:YES completion:nil];
|
|
|
- // }
|
|
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- (void)showBarcodeInput {
|
|
- (void)showBarcodeInput {
|
|
@@ -127,8 +157,10 @@
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-- (void)receiveImage:(UIImage *)img {
|
|
|
|
|
-
|
|
|
|
|
|
|
+- (void)showTopImage {
|
|
|
|
|
+ NSDictionary *item = [self.photos firstObject];
|
|
|
|
|
+ UIImage *img = [item objectForKey:@"photo"];
|
|
|
|
|
+ [self receiveImage:img];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- (NSString *)saveImage:(UIImage *)img {
|
|
- (NSString *)saveImage:(UIImage *)img {
|
|
@@ -233,7 +265,8 @@
|
|
|
@"photo" : image,
|
|
@"photo" : image,
|
|
|
@"check" : @(NO),
|
|
@"check" : @(NO),
|
|
|
@"file" : [path lastPathComponent],
|
|
@"file" : [path lastPathComponent],
|
|
|
- @"md5" : md5
|
|
|
|
|
|
|
+ @"md5" : md5,
|
|
|
|
|
+ @"path" : path
|
|
|
};
|
|
};
|
|
|
[self.photos addObject:photoDic];
|
|
[self.photos addObject:photoDic];
|
|
|
self.photoCount++;
|
|
self.photoCount++;
|
|
@@ -256,4 +289,10 @@
|
|
|
self.barcode = textField.text;
|
|
self.barcode = textField.text;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+#pragma mark - SubClass Override
|
|
|
|
|
+
|
|
|
|
|
+- (void)receiveImage:(UIImage *)img {
|
|
|
|
|
+
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
@end
|
|
@end
|