Procházet zdrojové kódy

1.修改iOS RAImage拍照和扫码。

Pen Li před 7 roky
rodič
revize
99afd495e1

+ 129 - 2
RA Image/RA Image.xcodeproj/project.pbxproj

@@ -7,6 +7,17 @@
 	objects = {
 
 /* Begin PBXBuildFile section */
+		4203E5FD21BA5E88003E90BD /* QRCode.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4203E5F321BA5E88003E90BD /* QRCode.storyboard */; };
+		4203E5FE21BA5E88003E90BD /* RAQRCodeScannerViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4203E5F521BA5E88003E90BD /* RAQRCodeScannerViewController.m */; };
+		4203E5FF21BA5E88003E90BD /* Camera.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4203E5F721BA5E88003E90BD /* Camera.storyboard */; };
+		4203E60021BA5E88003E90BD /* camera.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 4203E5F821BA5E88003E90BD /* camera.xcassets */; };
+		4203E60121BA5E88003E90BD /* RACameraViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4203E5FA21BA5E88003E90BD /* RACameraViewController.m */; };
+		4203E60221BA5E88003E90BD /* RATakePhotoPreviewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4203E5FC21BA5E88003E90BD /* RATakePhotoPreviewController.m */; };
+		4203E61021BA65F5003E90BD /* RAPhotoPreviewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4203E60721BA65F5003E90BD /* RAPhotoPreviewController.m */; };
+		4203E61121BA65F5003E90BD /* RAPhotoPreview.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 4203E60A21BA65F5003E90BD /* RAPhotoPreview.xcassets */; };
+		4203E61221BA65F5003E90BD /* PhotoList.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4203E60C21BA65F5003E90BD /* PhotoList.storyboard */; };
+		4203E61321BA65F5003E90BD /* PhotoPreviewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 4203E60F21BA65F5003E90BD /* PhotoPreviewCell.m */; };
+		4203E61721BA66EF003E90BD /* RAPhotoPreviewModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 4203E61621BA66EF003E90BD /* RAPhotoPreviewModel.m */; };
 		42056E7E1EB989AB0010597A /* JLKeyboardListener.m in Sources */ = {isa = PBXBuildFile; fileRef = 42056E7D1EB989AB0010597A /* JLKeyboardListener.m */; };
 		42056E871EB9CF5D0010597A /* BasicModeViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 42056E861EB9CF5D0010597A /* BasicModeViewController.m */; };
 		426E6B1F1EB8558400942BE1 /* RootModeCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 426E6B1E1EB8558400942BE1 /* RootModeCell.m */; };
@@ -79,6 +90,25 @@
 /* End PBXBuildFile section */
 
 /* Begin PBXFileReference section */
+		4203E5F321BA5E88003E90BD /* QRCode.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = QRCode.storyboard; sourceTree = "<group>"; };
+		4203E5F421BA5E88003E90BD /* RAQRCodeScannerViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RAQRCodeScannerViewController.h; sourceTree = "<group>"; };
+		4203E5F521BA5E88003E90BD /* RAQRCodeScannerViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RAQRCodeScannerViewController.m; sourceTree = "<group>"; };
+		4203E5F721BA5E88003E90BD /* Camera.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Camera.storyboard; sourceTree = "<group>"; };
+		4203E5F821BA5E88003E90BD /* camera.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = camera.xcassets; sourceTree = "<group>"; };
+		4203E5F921BA5E88003E90BD /* RACameraViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RACameraViewController.h; sourceTree = "<group>"; };
+		4203E5FA21BA5E88003E90BD /* RACameraViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RACameraViewController.m; sourceTree = "<group>"; };
+		4203E5FB21BA5E88003E90BD /* RATakePhotoPreviewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RATakePhotoPreviewController.h; sourceTree = "<group>"; };
+		4203E5FC21BA5E88003E90BD /* RATakePhotoPreviewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RATakePhotoPreviewController.m; sourceTree = "<group>"; };
+		4203E60321BA633C003E90BD /* RACamera.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RACamera.h; sourceTree = "<group>"; };
+		4203E60621BA65F5003E90BD /* RAPhotoPreviewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RAPhotoPreviewController.h; sourceTree = "<group>"; };
+		4203E60721BA65F5003E90BD /* RAPhotoPreviewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RAPhotoPreviewController.m; sourceTree = "<group>"; };
+		4203E60921BA65F5003E90BD /* RAPhotoDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RAPhotoDelegate.h; sourceTree = "<group>"; };
+		4203E60A21BA65F5003E90BD /* RAPhotoPreview.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = RAPhotoPreview.xcassets; sourceTree = "<group>"; };
+		4203E60C21BA65F5003E90BD /* PhotoList.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = PhotoList.storyboard; sourceTree = "<group>"; };
+		4203E60E21BA65F5003E90BD /* PhotoPreviewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PhotoPreviewCell.h; sourceTree = "<group>"; };
+		4203E60F21BA65F5003E90BD /* PhotoPreviewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PhotoPreviewCell.m; sourceTree = "<group>"; };
+		4203E61521BA66EF003E90BD /* RAPhotoPreviewModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RAPhotoPreviewModel.h; sourceTree = "<group>"; };
+		4203E61621BA66EF003E90BD /* RAPhotoPreviewModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RAPhotoPreviewModel.m; sourceTree = "<group>"; };
 		42056E7C1EB989AB0010597A /* JLKeyboardListener.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JLKeyboardListener.h; sourceTree = "<group>"; };
 		42056E7D1EB989AB0010597A /* JLKeyboardListener.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JLKeyboardListener.m; sourceTree = "<group>"; };
 		42056E851EB9CF5D0010597A /* BasicModeViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BasicModeViewController.h; sourceTree = "<group>"; };
@@ -222,6 +252,88 @@
 /* End PBXFrameworksBuildPhase section */
 
 /* Begin PBXGroup section */
+		4203E5F221BA5E88003E90BD /* QRCode */ = {
+			isa = PBXGroup;
+			children = (
+				4203E5F321BA5E88003E90BD /* QRCode.storyboard */,
+				4203E5F421BA5E88003E90BD /* RAQRCodeScannerViewController.h */,
+				4203E5F521BA5E88003E90BD /* RAQRCodeScannerViewController.m */,
+			);
+			name = QRCode;
+			path = ../common/QRCode;
+			sourceTree = "<group>";
+		};
+		4203E5F621BA5E88003E90BD /* Camera */ = {
+			isa = PBXGroup;
+			children = (
+				4203E5F721BA5E88003E90BD /* Camera.storyboard */,
+				4203E5F821BA5E88003E90BD /* camera.xcassets */,
+				4203E5F921BA5E88003E90BD /* RACameraViewController.h */,
+				4203E5FA21BA5E88003E90BD /* RACameraViewController.m */,
+				4203E5FB21BA5E88003E90BD /* RATakePhotoPreviewController.h */,
+				4203E5FC21BA5E88003E90BD /* RATakePhotoPreviewController.m */,
+				4203E60321BA633C003E90BD /* RACamera.h */,
+			);
+			name = Camera;
+			path = ../common/Camera;
+			sourceTree = "<group>";
+		};
+		4203E60421BA65F5003E90BD /* InfinitePhoto */ = {
+			isa = PBXGroup;
+			children = (
+				4203E60521BA65F5003E90BD /* Controller */,
+				4203E60821BA65F5003E90BD /* Delegate */,
+				4203E60A21BA65F5003E90BD /* RAPhotoPreview.xcassets */,
+				4203E60B21BA65F5003E90BD /* Storyboard */,
+				4203E60D21BA65F5003E90BD /* View */,
+			);
+			name = InfinitePhoto;
+			path = ../common/InfinitePhoto;
+			sourceTree = "<group>";
+		};
+		4203E60521BA65F5003E90BD /* Controller */ = {
+			isa = PBXGroup;
+			children = (
+				4203E60621BA65F5003E90BD /* RAPhotoPreviewController.h */,
+				4203E60721BA65F5003E90BD /* RAPhotoPreviewController.m */,
+			);
+			path = Controller;
+			sourceTree = "<group>";
+		};
+		4203E60821BA65F5003E90BD /* Delegate */ = {
+			isa = PBXGroup;
+			children = (
+				4203E60921BA65F5003E90BD /* RAPhotoDelegate.h */,
+			);
+			path = Delegate;
+			sourceTree = "<group>";
+		};
+		4203E60B21BA65F5003E90BD /* Storyboard */ = {
+			isa = PBXGroup;
+			children = (
+				4203E60C21BA65F5003E90BD /* PhotoList.storyboard */,
+			);
+			path = Storyboard;
+			sourceTree = "<group>";
+		};
+		4203E60D21BA65F5003E90BD /* View */ = {
+			isa = PBXGroup;
+			children = (
+				4203E60E21BA65F5003E90BD /* PhotoPreviewCell.h */,
+				4203E60F21BA65F5003E90BD /* PhotoPreviewCell.m */,
+			);
+			path = View;
+			sourceTree = "<group>";
+		};
+		4203E61421BA66CD003E90BD /* RAPhotoPreviewModel */ = {
+			isa = PBXGroup;
+			children = (
+				4203E61521BA66EF003E90BD /* RAPhotoPreviewModel.h */,
+				4203E61621BA66EF003E90BD /* RAPhotoPreviewModel.m */,
+			);
+			path = RAPhotoPreviewModel;
+			sourceTree = "<group>";
+		};
 		42056E7B1EB989AB0010597A /* KeyboardListener */ = {
 			isa = PBXGroup;
 			children = (
@@ -303,6 +415,7 @@
 		42BC2CFC1EBAC3D40016B30D /* PhotoList */ = {
 			isa = PBXGroup;
 			children = (
+				4203E61421BA66CD003E90BD /* RAPhotoPreviewModel */,
 				42BC2D001EBAC4310016B30D /* RAImage_PhotoList.storyboard */,
 				42BC2CFD1EBAC4050016B30D /* PhotoListViewController.h */,
 				42BC2CFE1EBAC4050016B30D /* PhotoListViewController.m */,
@@ -522,6 +635,9 @@
 		71DCDC2B1EAF234E00BA045A = {
 			isa = PBXGroup;
 			children = (
+				4203E60421BA65F5003E90BD /* InfinitePhoto */,
+				4203E5F621BA5E88003E90BD /* Camera */,
+				4203E5F221BA5E88003E90BD /* QRCode */,
 				42E1B0FF1EB1C90700EEF27C /* BasicViewController */,
 				71DCDC361EAF234E00BA045A /* RA Image */,
 				71DCDC351EAF234E00BA045A /* Products */,
@@ -652,10 +768,15 @@
 				71DCDC441EAF234E00BA045A /* Assets.xcassets in Resources */,
 				71DCDC501EAF353000BA045A /* modelist.json in Resources */,
 				426E6B291EB8720400942BE1 /* Mode.storyboard in Resources */,
+				4203E60021BA5E88003E90BD /* camera.xcassets in Resources */,
+				4203E5FF21BA5E88003E90BD /* Camera.storyboard in Resources */,
+				4203E61121BA65F5003E90BD /* RAPhotoPreview.xcassets in Resources */,
+				4203E61221BA65F5003E90BD /* PhotoList.storyboard in Resources */,
 				71114AEE1EB2DEF900D2200C /* cam_scan.storyboard in Resources */,
 				42CE45CE217D73E6003ECD01 /* signature.storyboard in Resources */,
 				71DCDC421EAF234E00BA045A /* RAImage.storyboard in Resources */,
 				71114AB31EB1C5C800D2200C /* LICENSE in Resources */,
+				4203E5FD21BA5E88003E90BD /* QRCode.storyboard in Resources */,
 				42BC2D011EBAC4310016B30D /* RAImage_PhotoList.storyboard in Resources */,
 				42E1B1041EB1CCB200EEF27C /* login.json in Resources */,
 				42CE45C6217D6D38003ECD01 /* pod.storyboard in Resources */,
@@ -677,6 +798,7 @@
 				42BC2D0C1EBB00FD0016B30D /* PhotoPreviewController.m in Sources */,
 				426E6B241EB85C2B00942BE1 /* PopModeViewController.m in Sources */,
 				42CE45C4217D6D0D003ECD01 /* PODModeViewController.m in Sources */,
+				4203E60121BA5E88003E90BD /* RACameraViewController.m in Sources */,
 				71114AF01EB2DEF900D2200C /* RAMenu.m in Sources */,
 				71114AC61EB1C73B00D2200C /* ioapi.c in Sources */,
 				42056E7E1EB989AB0010597A /* JLKeyboardListener.m in Sources */,
@@ -685,7 +807,9 @@
 				71114A9D1EB1BCB400D2200C /* LoginViewController.m in Sources */,
 				71114AB51EB1C5C800D2200C /* NSData+CommonCrypto.m in Sources */,
 				71114AC71EB1C73B00D2200C /* mztools.c in Sources */,
+				4203E61321BA65F5003E90BD /* PhotoPreviewCell.m in Sources */,
 				426E6B271EB85C4200942BE1 /* ModelModeViewController.m in Sources */,
+				4203E61021BA65F5003E90BD /* RAPhotoPreviewController.m in Sources */,
 				42A829C71EBC0FAC00898B8A /* ManufacturerCell.m in Sources */,
 				71DCDC3F1EAF234E00BA045A /* RootViewController.m in Sources */,
 				42BC6FFA1EC1ACF9004A5F30 /* UploadSettingController.m in Sources */,
@@ -705,11 +829,14 @@
 				717A37AE1ED6BF0700E09FB6 /* ImageUtils.m in Sources */,
 				42BC2D091EBAC75F0016B30D /* TouchImageView.m in Sources */,
 				42A829C31EBC0F8300898B8A /* ManufacturerListController.m in Sources */,
+				4203E5FE21BA5E88003E90BD /* RAQRCodeScannerViewController.m in Sources */,
 				71114AB61EB1C5C800D2200C /* NSString+Base64.m in Sources */,
 				71114AA61EB1C50D00D2200C /* RAUtils.m in Sources */,
 				71749AFD1ECC199300018EEC /* UIImage+fixOrientation.m in Sources */,
+				4203E60221BA5E88003E90BD /* RATakePhotoPreviewController.m in Sources */,
 				71DCDC3C1EAF234E00BA045A /* AppDelegate.m in Sources */,
 				71961CB21EC00DDD002C4096 /* RAUploadOperation.m in Sources */,
+				4203E61721BA66EF003E90BD /* RAPhotoPreviewModel.m in Sources */,
 				42D64CC11FD12B21003F49F9 /* RAConvertor.m in Sources */,
 				429F25221EC9AA4200C22ABB /* TakePhotoPreviewController.m in Sources */,
 				42E1B1021EB1C92000EEF27C /* BasicViewController.m in Sources */,
@@ -859,7 +986,7 @@
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
 				DEVELOPMENT_TEAM = HXWLAA5YN5;
 				INFOPLIST_FILE = "RA Image/Info.plist";
-				IPHONEOS_DEPLOYMENT_TARGET = 8.0;
+				IPHONEOS_DEPLOYMENT_TARGET = 9.0;
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
 				PRODUCT_BUNDLE_IDENTIFIER = "usai.redant.RA-Image";
 				PRODUCT_NAME = "$(TARGET_NAME)";
@@ -874,7 +1001,7 @@
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
 				DEVELOPMENT_TEAM = HXWLAA5YN5;
 				INFOPLIST_FILE = "RA Image/Info.plist";
-				IPHONEOS_DEPLOYMENT_TARGET = 8.0;
+				IPHONEOS_DEPLOYMENT_TARGET = 9.0;
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
 				PRODUCT_BUNDLE_IDENTIFIER = "usai.redant.RA-Image";
 				PRODUCT_NAME = "$(TARGET_NAME)";

+ 113 - 60
RA Image/RA Image/BasicModeViewController.m

@@ -14,6 +14,9 @@
 #import <AssetsLibrary/AssetsLibrary.h>
 #import "TakePhotoPreviewController.h"
 #import "ImageUtils.h"
+#import "RACameraViewController.h"
+#import "RAQRCodeScannerViewController.h"
+#import "UIImage+fixOrientation.h"
 
 
 #pragma clang diagnostic push 
@@ -174,20 +177,37 @@
 
 - (void)showScanner {
     __weak typeof(self) weakself = self;
-    ScannerViewController *scannerVC = [[UIStoryboard storyboardWithName:@"cam_scan" bundle:nil] instantiateViewControllerWithIdentifier:@"NewScannerViewController"];
-    scannerVC.returnCode = ^(NSString *code) {
-        // 扫描成功保存扫描值
-        if (code.length) {
+//    ScannerViewController *scannerVC = [[UIStoryboard storyboardWithName:@"cam_scan" bundle:nil] instantiateViewControllerWithIdentifier:@"NewScannerViewController"];
+//    scannerVC.returnCode = ^(NSString *code) {
+//        // 扫描成功保存扫描值
+//        if (code.length) {
+//
+//            if (weakself) {
+//                __strong typeof(weakself) strongself = weakself;
+//
+//                strongself.barcode = code;
+//            }
+//
+//        }
+//    };
+//    [self presentViewController:scannerVC animated:YES completion:nil];
+    
+    RAQRCodeScannerViewController *scannerVC = [RAQRCodeScannerViewController viewControllerFromStoryboard];
+    scannerVC.completion = ^(NSString *value) {
+        
+        if (value.length) {
             
             if (weakself) {
                 __strong typeof(weakself) strongself = weakself;
-                
-                strongself.barcode = code;
+                strongself.barcode = value;
             }
             
         }
+
+        
     };
-    [self presentViewController:scannerVC animated:YES completion:nil];
+    
+    [self.navigationController pushViewController:scannerVC animated:YES];
 }
 
 - (void)showCamera {
@@ -213,6 +233,39 @@
         return;
     }
     
+    __weak typeof(self) weakself = self;
+    RACameraViewController *cameraVC = [RACameraViewController viewControllerFromStoryboard];
+    cameraVC.completion = ^(UIImage *img) {
+        
+        if (img) {
+            dispatch_async(dispatch_get_global_queue(0, 0), ^{
+                UIImage *newImg = [img fixOrientation];
+                NSString *path = [weakself saveImage:newImg];
+                dispatch_async(dispatch_get_main_queue(), ^{
+                    if (path) {// 保存成功
+                        [weakself receiveImage:newImg];
+                        NSString *md5 = [RAUtils md5WithFile:path];
+                        NSMutableDictionary *photoDic = @{
+                                                          @"check" : @(NO),
+                                                          @"file"  : [path lastPathComponent],
+                                                          @"md5"   : md5,
+                                                          @"path"  : path,
+                                                          }.mutableCopy;
+                        [weakself.photos insertObject:photoDic atIndex:0];
+                        weakself.photoCount++;
+                    } else {
+//                        [RAUtils message_alert:@"Save photo failed, storage full?" title:@"Warning" controller:weakPreVC];
+                    }
+                });
+                
+            });
+        }
+        
+    };
+    cameraVC.takeMode = RACameraTakeModeTakeASerial;
+    cameraVC.fromVC = self;
+    [self.navigationController pushViewController:cameraVC animated:YES];
+    
 //    UIImagePickerController *imgPicker = [[UIImagePickerController alloc] init];
 //    imgPicker.delegate = self;
 //    
@@ -221,59 +274,59 @@
 //    [self presentViewController:imgPicker animated:YES completion:nil];
 
     
-    CGFloat w = CGRectGetWidth(self.view.frame);
-    CGFloat h = CGRectGetHeight(self.view.frame);
-    if (self.interfaceOrientation == UIInterfaceOrientationLandscapeLeft || self.interfaceOrientation == UIInterfaceOrientationLandscapeRight) {
-        // 修复横屏时打开相机Control位置不正确
-        CGFloat tmp = w;
-        w = h;
-        h = tmp;
-    }
-    // 自定义相机控制视图
-    UIImagePickerController *imgPicker = [[UIImagePickerController alloc] init];
-    imgPicker.delegate = self;
-    imgPicker.sourceType = UIImagePickerControllerSourceTypeCamera;
-    imgPicker.allowsEditing = NO;
-    imgPicker.showsCameraControls  = NO;
-    UIView* overlay = [[UIView alloc]initWithFrame:CGRectMake(0, h - 150 , w, 150)];
-
-    // Cancel
-    UIButton *cancelBtn = [UIButton buttonWithType:UIButtonTypeCustom];
-    cancelBtn.frame = CGRectMake(20, (150 - 40) * 0.5, 60, 40);
-    [cancelBtn setTitle:@"cancel" forState:UIControlStateNormal];
-    [cancelBtn addTarget:self action:@selector(cancelCameraClick:) forControlEvents:UIControlEventTouchUpInside];
-    [overlay addSubview:cancelBtn];
-    
-    // Take
-    UIButton *takeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
-    takeBtn.frame = CGRectMake((w - 60) * 0.5, (150 - 60) * 0.5, 60, 60);
-//    [takeBtn setTitle:@"take" forState:UIControlStateNormal];
-    [takeBtn setImage:[UIImage imageNamed:@"take_photo"] forState:UIControlStateNormal];
-    [takeBtn addTarget:self action:@selector(takePhotoClick:) forControlEvents:UIControlEventTouchUpInside];
-    [overlay addSubview:takeBtn];
-    
-    // flash
-    UIButton *flashBtn = [UIButton buttonWithType:UIButtonTypeCustom];
-    flashBtn.frame = CGRectMake(w - 80, (150 - 60) * 0.5, 60, 60);
-    [flashBtn setImage:[UIImage imageNamed:@"flash_auto"] forState:UIControlStateNormal];
-    [flashBtn addTarget:self action:@selector(flashBtnClick:) forControlEvents:UIControlEventTouchUpInside];
-    [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];
-    
-    
-    // 相机属性设置得在设置SourceType后设置
-    imgPicker.cameraFlashMode = UIImagePickerControllerCameraFlashModeAuto;
-    //把自定义的view设置到imagepickercontroller的overlay属性中
-    imgPicker.cameraOverlayView = overlay;
-    
-    self.imgPicker = imgPicker;
-    [self presentViewController:imgPicker animated:YES completion:nil];
+//    CGFloat w = CGRectGetWidth(self.view.frame);
+//    CGFloat h = CGRectGetHeight(self.view.frame);
+//    if (self.interfaceOrientation == UIInterfaceOrientationLandscapeLeft || self.interfaceOrientation == UIInterfaceOrientationLandscapeRight) {
+//        // 修复横屏时打开相机Control位置不正确
+//        CGFloat tmp = w;
+//        w = h;
+//        h = tmp;
+//    }
+//    // 自定义相机控制视图
+//    UIImagePickerController *imgPicker = [[UIImagePickerController alloc] init];
+//    imgPicker.delegate = self;
+//    imgPicker.sourceType = UIImagePickerControllerSourceTypeCamera;
+//    imgPicker.allowsEditing = NO;
+//    imgPicker.showsCameraControls  = NO;
+//    UIView* overlay = [[UIView alloc]initWithFrame:CGRectMake(0, h - 150 , w, 150)];
+//
+//    // Cancel
+//    UIButton *cancelBtn = [UIButton buttonWithType:UIButtonTypeCustom];
+//    cancelBtn.frame = CGRectMake(20, (150 - 40) * 0.5, 60, 40);
+//    [cancelBtn setTitle:@"cancel" forState:UIControlStateNormal];
+//    [cancelBtn addTarget:self action:@selector(cancelCameraClick:) forControlEvents:UIControlEventTouchUpInside];
+//    [overlay addSubview:cancelBtn];
+//
+//    // Take
+//    UIButton *takeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
+//    takeBtn.frame = CGRectMake((w - 60) * 0.5, (150 - 60) * 0.5, 60, 60);
+////    [takeBtn setTitle:@"take" forState:UIControlStateNormal];
+//    [takeBtn setImage:[UIImage imageNamed:@"take_photo"] forState:UIControlStateNormal];
+//    [takeBtn addTarget:self action:@selector(takePhotoClick:) forControlEvents:UIControlEventTouchUpInside];
+//    [overlay addSubview:takeBtn];
+//
+//    // flash
+//    UIButton *flashBtn = [UIButton buttonWithType:UIButtonTypeCustom];
+//    flashBtn.frame = CGRectMake(w - 80, (150 - 60) * 0.5, 60, 60);
+//    [flashBtn setImage:[UIImage imageNamed:@"flash_auto"] forState:UIControlStateNormal];
+//    [flashBtn addTarget:self action:@selector(flashBtnClick:) forControlEvents:UIControlEventTouchUpInside];
+//    [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];
+//
+//
+//    // 相机属性设置得在设置SourceType后设置
+//    imgPicker.cameraFlashMode = UIImagePickerControllerCameraFlashModeAuto;
+//    //把自定义的view设置到imagepickercontroller的overlay属性中
+//    imgPicker.cameraOverlayView = overlay;
+//
+//    self.imgPicker = imgPicker;
+//    [self presentViewController:imgPicker animated:YES completion:nil];
 }
 
 - (void)showPhotoLibrary {

+ 19 - 5
RA Image/RA Image/PhotoListViewController.m

@@ -10,7 +10,9 @@
 #import "PhotoCell.h"
 #import "PhotoPreviewController.h"
 #import "BasicModeViewController.h"
-#import "NewPhotoPreviewController.h"
+//#import "NewPhotoPreviewController.h"
+#import "RAPhotoPreviewController.h"
+#import "RAPhotoPreviewModel/RAPhotoPreviewModel.h"
 
 @interface PhotoListViewController ()<UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout,PhotoCellDelegate>
 
@@ -136,10 +138,22 @@
 - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
     // 点击Cell不响应需要在viewDidLoad方法中removeFirstResponderTap
 //    PhotoPreviewController *previewVC = (PhotoPreviewController *)[self viewControllerInStoryboard:@"RAImage_PhotoList" withId:@"PhotoPreviewController"];
-    NewPhotoPreviewController *previewVC = (NewPhotoPreviewController *)[self viewControllerInStoryboard:@"RAImage_PhotoList" withId:@"NewPhotoPreviewController"];
-    previewVC.photos = self.photos;
-    previewVC.currentIndex = indexPath.row;
-    [self.navigationController pushViewController:previewVC animated:YES];
+//    NewPhotoPreviewController *previewVC = (NewPhotoPreviewController *)[self viewControllerInStoryboard:@"RAImage_PhotoList" withId:@"NewPhotoPreviewController"];
+//    previewVC.photos = self.photos;
+//    previewVC.currentIndex = indexPath.row;
+//    [self.navigationController pushViewController:previewVC animated:YES];
+    
+    NSMutableArray *mArr = [NSMutableArray array];
+    for (NSDictionary *item in self.photos) {
+        NSString *path = [item objectForKey:@"path"];
+        RAPhotoPreviewModel *model = [[RAPhotoPreviewModel alloc] init];
+        model.path = path;
+        [mArr addObject:model];
+    }
+    
+    RAPhotoPreviewController *previewController = [RAPhotoPreviewController ra_photoPreviewControllerWithPhotoItems:mArr offset:indexPath.row];
+    
+    [self presentViewController:previewController animated:YES completion:nil];
 }
 
 #pragma mark - Flow Layout

+ 1 - 1
RA Image/RA Image/RANetwork.m

@@ -119,7 +119,7 @@
                                     }.mutableCopy;
     AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
     
-    NSData *data = [self get_json:appDelegate.address parameters:params file:nil];
+    NSData *data = [self get_json:@"http://192.168.0.130:8080/MyWeb/Test" parameters:params file:nil];
     NSDictionary *resultDic = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableLeaves error:nil];
     return resultDic;
 }

+ 19 - 0
RA Image/RA Image/RAPhotoPreviewModel/RAPhotoPreviewModel.h

@@ -0,0 +1,19 @@
+//
+//  RAPhotoPreviewModel.h
+//  RA Image
+//
+//  Created by Jack on 2018/12/7.
+//  Copyright © 2018年 USAI. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+#import "RAPhotoDelegate.h"
+
+@interface RAPhotoPreviewModel : NSObject <RAPhotoItemDelegate>
+
+@property (nonatomic,weak) id<RAPhotoItemUIDelegate> delegate;
+@property (nonatomic,strong) UIImage *image;
+@property (nonatomic,copy) NSString *path;
+
+@end
+

+ 26 - 0
RA Image/RA Image/RAPhotoPreviewModel/RAPhotoPreviewModel.m

@@ -0,0 +1,26 @@
+//
+//  RAPhotoPreviewModel.m
+//  RA Image
+//
+//  Created by Jack on 2018/12/7.
+//  Copyright © 2018年 USAI. All rights reserved.
+//
+
+#import "RAPhotoPreviewModel.h"
+
+@implementation RAPhotoPreviewModel
+
+- (void)setPath:(NSString *)path {
+    _path = path;
+    
+    dispatch_async(dispatch_get_global_queue(0, 0), ^{
+        if (_path == nil) {
+            self.image = nil;
+        } else {
+            UIImage *img = [UIImage imageWithContentsOfFile:path];
+            self.image = img;
+        }
+    });
+}
+
+@end

+ 17 - 17
RA Image/RA Image/pod.storyboard

@@ -1,11 +1,11 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14313.18" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
-    <device id="retina4_7" orientation="portrait">
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14460.31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
+    <device id="retina4_0" orientation="portrait">
         <adaptation id="fullscreen"/>
     </device>
     <dependencies>
         <deployment identifier="iOS"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14283.14"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14460.20"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
     <scenes>
@@ -18,11 +18,11 @@
                         <viewControllerLayoutGuide type="bottom" id="Vb1-aL-kW0"/>
                     </layoutGuides>
                     <view key="view" contentMode="scaleToFill" id="kMJ-qN-sNr">
-                        <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
+                        <rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                         <subviews>
                             <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="a7p-Is-pkn">
-                                <rect key="frame" x="47.5" y="50" width="280" height="280"/>
+                                <rect key="frame" x="20" y="50" width="280" height="280"/>
                                 <constraints>
                                     <constraint firstAttribute="height" constant="280" id="3uL-Sz-8iY"/>
                                     <constraint firstAttribute="height" constant="300" id="K6U-1F-65K"/>
@@ -34,11 +34,11 @@
                                 <variation key="default">
                                     <mask key="constraints">
                                         <exclude reference="3uL-Sz-8iY"/>
-                                        <exclude reference="QS0-oE-Lc4"/>
                                         <exclude reference="K6U-1F-65K"/>
-                                        <exclude reference="sHM-ee-xWI"/>
+                                        <exclude reference="QS0-oE-Lc4"/>
                                         <exclude reference="Z1A-Hg-I6w"/>
                                         <exclude reference="chC-74-nMq"/>
+                                        <exclude reference="sHM-ee-xWI"/>
                                     </mask>
                                 </variation>
                                 <variation key="heightClass=compact-widthClass=compact">
@@ -57,8 +57,8 @@
                                     <mask key="constraints">
                                         <include reference="3uL-Sz-8iY"/>
                                         <exclude reference="QS0-oE-Lc4"/>
-                                        <include reference="sHM-ee-xWI"/>
                                         <exclude reference="chC-74-nMq"/>
+                                        <include reference="sHM-ee-xWI"/>
                                     </mask>
                                 </variation>
                                 <connections>
@@ -66,7 +66,7 @@
                                 </connections>
                             </button>
                             <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="kIh-Dp-XpI">
-                                <rect key="frame" x="47.5" y="560" width="60" height="60"/>
+                                <rect key="frame" x="20" y="461" width="60" height="60"/>
                                 <constraints>
                                     <constraint firstAttribute="width" constant="60" id="5ZT-hx-KaN"/>
                                 </constraints>
@@ -91,7 +91,7 @@
                                 </connections>
                             </button>
                             <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="utR-SX-vR9">
-                                <rect key="frame" x="157.5" y="560" width="60" height="60"/>
+                                <rect key="frame" x="130" y="461" width="60" height="60"/>
                                 <constraints>
                                     <constraint firstAttribute="height" constant="60" id="42s-55-8Tl"/>
                                 </constraints>
@@ -101,13 +101,13 @@
                                 </connections>
                             </button>
                             <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="PIID:" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="fCY-Do-hbH">
-                                <rect key="frame" x="47.5" y="353" width="280" height="27"/>
+                                <rect key="frame" x="20" y="353" width="280" height="27"/>
                                 <fontDescription key="fontDescription" type="system" pointSize="17"/>
                                 <nil key="textColor"/>
                                 <nil key="highlightedColor"/>
                             </label>
                             <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="a7e-bt-oTC">
-                                <rect key="frame" x="297.5" y="353" width="30" height="27"/>
+                                <rect key="frame" x="270" y="353" width="30" height="27"/>
                                 <constraints>
                                     <constraint firstAttribute="width" constant="30" id="FiY-CX-2mo"/>
                                 </constraints>
@@ -120,14 +120,14 @@
                                 </connections>
                             </button>
                             <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Oef-9h-Tp8">
-                                <rect key="frame" x="267.5" y="560" width="60" height="60"/>
+                                <rect key="frame" x="240" y="461" width="60" height="60"/>
                                 <state key="normal" backgroundImage="upload"/>
                                 <connections>
                                     <action selector="uploadBtnClick:" destination="I0z-KN-bl5" eventType="touchUpInside" id="4RX-PK-Mlw"/>
                                 </connections>
                             </button>
                             <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="No Photos" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="rhm-0R-9Ma">
-                                <rect key="frame" x="47.5" y="310" width="280" height="20"/>
+                                <rect key="frame" x="20" y="310" width="280" height="20"/>
                                 <constraints>
                                     <constraint firstAttribute="height" constant="20" id="r64-ty-wkN"/>
                                 </constraints>
@@ -136,7 +136,7 @@
                                 <nil key="highlightedColor"/>
                             </label>
                             <imageView contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="tap_signature" translatesAutoresizingMaskIntoConstraints="NO" id="RqS-9Z-Sx4">
-                                <rect key="frame" x="47.5" y="385" width="280" height="170"/>
+                                <rect key="frame" x="20" y="385" width="280" height="71"/>
                             </imageView>
                         </subviews>
                         <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
@@ -226,7 +226,6 @@
                                 <exclude reference="e6H-SX-pIW"/>
                                 <exclude reference="qoK-En-j6n"/>
                                 <exclude reference="wxU-rx-5Xn"/>
-                                <exclude reference="nWh-OP-vjR"/>
                                 <exclude reference="9p6-dA-fSp"/>
                                 <exclude reference="Hvu-Sf-aUh"/>
                                 <exclude reference="MzH-WF-Q9y"/>
@@ -251,6 +250,7 @@
                                 <exclude reference="mob-hE-MBP"/>
                                 <exclude reference="vTL-Db-7b2"/>
                                 <exclude reference="xLf-Iz-yOl"/>
+                                <exclude reference="nWh-OP-vjR"/>
                             </mask>
                         </variation>
                         <variation key="heightClass=compact-widthClass=compact">
@@ -300,7 +300,6 @@
                                 <include reference="NFu-FS-o0X"/>
                                 <include reference="XVf-dN-a5C"/>
                                 <include reference="qoK-En-j6n"/>
-                                <include reference="nWh-OP-vjR"/>
                                 <include reference="Hvu-Sf-aUh"/>
                                 <include reference="PEi-ln-WNk"/>
                                 <include reference="bWY-vn-l0j"/>
@@ -311,6 +310,7 @@
                                 <include reference="P1B-fg-vr9"/>
                                 <include reference="STV-74-ZWe"/>
                                 <include reference="mob-hE-MBP"/>
+                                <include reference="nWh-OP-vjR"/>
                             </mask>
                         </variation>
                     </view>