Quellcode durchsuchen

1.完成iOS Apex & Drivers Update Order拍照。
2.完成iOS Apex & Drivers Update Order条码扫描。

Pen Li vor 8 Jahren
Ursprung
Commit
aa4c9b4d61
34 geänderte Dateien mit 1496 neuen und 20 gelöschten Zeilen
  1. 74 0
      Redant Drivers/Apex And Drivers.xcodeproj/project.pbxproj
  2. 148 0
      Redant Drivers/Apex And Drivers/Camera/Camera.storyboard
  3. 17 0
      Redant Drivers/Apex And Drivers/Camera/RACameraViewController.h
  4. 201 0
      Redant Drivers/Apex And Drivers/Camera/RACameraViewController.m
  5. 19 0
      Redant Drivers/Apex And Drivers/Camera/RATakePhotoPreviewController.h
  6. 268 0
      Redant Drivers/Apex And Drivers/Camera/RATakePhotoPreviewController.m
  7. 2 0
      Redant Drivers/Apex And Drivers/Detail/Action Selection/RADetailActionSelectionModel.h
  8. 1 0
      Redant Drivers/Apex And Drivers/Detail/Model/Collection/RADetailActionModel.m
  9. 1 1
      Redant Drivers/Apex And Drivers/Detail/RAOrderDetailViewController+TableViewDataSource.m
  10. 2 0
      Redant Drivers/Apex And Drivers/Home/RAHomeViewController.m
  11. 14 0
      Redant Drivers/Apex And Drivers/Info.plist
  12. 60 0
      Redant Drivers/Apex And Drivers/PhotoPreView/PhotoPreview.storyboard
  13. 17 0
      Redant Drivers/Apex And Drivers/PhotoPreView/RAPhotoPreviewController.h
  14. 74 0
      Redant Drivers/Apex And Drivers/PhotoPreView/RAPhotoPreviewController.m
  15. 71 0
      Redant Drivers/Apex And Drivers/QRCode/QRCode.storyboard
  16. 15 0
      Redant Drivers/Apex And Drivers/QRCode/RAQRCodeScannerViewController.h
  17. 188 0
      Redant Drivers/Apex And Drivers/QRCode/RAQRCodeScannerViewController.m
  18. 17 0
      Redant Drivers/Apex And Drivers/RAProgressHUD.h
  19. 70 0
      Redant Drivers/Apex And Drivers/RAProgressHUD.m
  20. 16 1
      Redant Drivers/Apex And Drivers/Update/Cell/RAEditMultInputCell.m
  21. 9 1
      Redant Drivers/Apex And Drivers/Update/Cell/RAEditPhotoCell.h
  22. 19 8
      Redant Drivers/Apex And Drivers/Update/Cell/RAEditPhotoCell.m
  23. 1 0
      Redant Drivers/Apex And Drivers/Update/Cell/RAEditScanInputCell.h
  24. 27 5
      Redant Drivers/Apex And Drivers/Update/Cell/RAEditScanInputCell.m
  25. 8 0
      Redant Drivers/Apex And Drivers/Update/Model/RAEditBaseModel.h
  26. 8 0
      Redant Drivers/Apex And Drivers/Update/Model/RAEditBaseModel.m
  27. 2 0
      Redant Drivers/Apex And Drivers/Update/Model/RAEditInputModel.h
  28. 12 0
      Redant Drivers/Apex And Drivers/Update/Model/RAEditInputModel.m
  29. 2 0
      Redant Drivers/Apex And Drivers/Update/Model/RAEditMultInputModel.h
  30. 13 1
      Redant Drivers/Apex And Drivers/Update/Model/RAEditMultInputModel.m
  31. 13 0
      Redant Drivers/Apex And Drivers/Update/Model/RAEditPhotoModel.m
  32. 2 1
      Redant Drivers/Apex And Drivers/Update/RAOrderEditViewController+TableDataSource.h
  33. 41 1
      Redant Drivers/Apex And Drivers/Update/RAOrderEditViewController+TableDataSource.m
  34. 64 1
      Redant Drivers/Apex And Drivers/Update/RAOrderEditViewController.m

+ 74 - 0
Redant Drivers/Apex And Drivers.xcodeproj/project.pbxproj

@@ -21,6 +21,15 @@
 		4205FD6C20C13E0700DB42B4 /* RAHomeViewController+HomeTableDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 4205FD6B20C13E0700DB42B4 /* RAHomeViewController+HomeTableDelegate.m */; };
 		4205FD6F20C13E2700DB42B4 /* RAHomeViewController+HomeTableDataSource.m in Sources */ = {isa = PBXBuildFile; fileRef = 4205FD6E20C13E2700DB42B4 /* RAHomeViewController+HomeTableDataSource.m */; };
 		4205FD7220C1465400DB42B4 /* RAHomeOrderModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 4205FD7120C1465400DB42B4 /* RAHomeOrderModel.m */; };
+		424204DC20C61561005AEED9 /* RAQRCodeScannerViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 424204DB20C61561005AEED9 /* RAQRCodeScannerViewController.m */; };
+		424204DE20C6156E005AEED9 /* QRCode.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 424204DD20C6156E005AEED9 /* QRCode.storyboard */; };
+		424204E220C65817005AEED9 /* RACameraViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 424204E120C65817005AEED9 /* RACameraViewController.m */; };
+		424204E420C65827005AEED9 /* Camera.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 424204E320C65827005AEED9 /* Camera.storyboard */; };
+		424204E720C668AE005AEED9 /* RATakePhotoPreviewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 424204E620C668AE005AEED9 /* RATakePhotoPreviewController.m */; };
+		424204EA20C6698A005AEED9 /* UIImage+fixOrientation.m in Sources */ = {isa = PBXBuildFile; fileRef = 424204E920C6698A005AEED9 /* UIImage+fixOrientation.m */; };
+		424204EE20C66D20005AEED9 /* RAPhotoPreviewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 424204ED20C66D20005AEED9 /* RAPhotoPreviewController.m */; };
+		424204F020C66D2D005AEED9 /* PhotoPreview.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 424204EF20C66D2D005AEED9 /* PhotoPreview.storyboard */; };
+		424204F320C68E02005AEED9 /* RAProgressHUD.m in Sources */ = {isa = PBXBuildFile; fileRef = 424204F220C68E02005AEED9 /* RAProgressHUD.m */; };
 		42529D2120C0E8EC000C0F4D /* NetworkUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = 42529D2020C0E8EC000C0F4D /* NetworkUtils.m */; };
 		42529D2520C0E97E000C0F4D /* RADataProvider.m in Sources */ = {isa = PBXBuildFile; fileRef = 42529D2420C0E97E000C0F4D /* RADataProvider.m */; };
 		42529D2B20C0EA0A000C0F4D /* RAUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = 42529D2A20C0EA0A000C0F4D /* RAUtils.m */; };
@@ -111,6 +120,21 @@
 		4205FD6E20C13E2700DB42B4 /* RAHomeViewController+HomeTableDataSource.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "RAHomeViewController+HomeTableDataSource.m"; sourceTree = "<group>"; };
 		4205FD7020C1465400DB42B4 /* RAHomeOrderModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RAHomeOrderModel.h; sourceTree = "<group>"; };
 		4205FD7120C1465400DB42B4 /* RAHomeOrderModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RAHomeOrderModel.m; sourceTree = "<group>"; };
+		424204DA20C61561005AEED9 /* RAQRCodeScannerViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RAQRCodeScannerViewController.h; sourceTree = "<group>"; };
+		424204DB20C61561005AEED9 /* RAQRCodeScannerViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RAQRCodeScannerViewController.m; sourceTree = "<group>"; };
+		424204DD20C6156E005AEED9 /* QRCode.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = QRCode.storyboard; sourceTree = "<group>"; };
+		424204E020C65817005AEED9 /* RACameraViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RACameraViewController.h; sourceTree = "<group>"; };
+		424204E120C65817005AEED9 /* RACameraViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RACameraViewController.m; sourceTree = "<group>"; };
+		424204E320C65827005AEED9 /* Camera.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = Camera.storyboard; sourceTree = "<group>"; };
+		424204E520C668AE005AEED9 /* RATakePhotoPreviewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RATakePhotoPreviewController.h; sourceTree = "<group>"; };
+		424204E620C668AE005AEED9 /* RATakePhotoPreviewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RATakePhotoPreviewController.m; sourceTree = "<group>"; };
+		424204E820C6698A005AEED9 /* UIImage+fixOrientation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "UIImage+fixOrientation.h"; path = "../../common/UIImage+fixOrientation.h"; sourceTree = "<group>"; };
+		424204E920C6698A005AEED9 /* UIImage+fixOrientation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "UIImage+fixOrientation.m"; path = "../../common/UIImage+fixOrientation.m"; sourceTree = "<group>"; };
+		424204EC20C66D20005AEED9 /* RAPhotoPreviewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RAPhotoPreviewController.h; sourceTree = "<group>"; };
+		424204ED20C66D20005AEED9 /* RAPhotoPreviewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RAPhotoPreviewController.m; sourceTree = "<group>"; };
+		424204EF20C66D2D005AEED9 /* PhotoPreview.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = PhotoPreview.storyboard; sourceTree = "<group>"; };
+		424204F120C68E02005AEED9 /* RAProgressHUD.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RAProgressHUD.h; sourceTree = "<group>"; };
+		424204F220C68E02005AEED9 /* RAProgressHUD.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RAProgressHUD.m; sourceTree = "<group>"; };
 		42529D1F20C0E8EB000C0F4D /* NetworkUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NetworkUtils.h; path = ../../common/NetworkUtils.h; sourceTree = "<group>"; };
 		42529D2020C0E8EC000C0F4D /* NetworkUtils.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = NetworkUtils.m; path = ../../common/NetworkUtils.m; sourceTree = "<group>"; };
 		42529D2320C0E97E000C0F4D /* RADataProvider.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RADataProvider.h; sourceTree = "<group>"; };
@@ -307,6 +331,38 @@
 			path = Home;
 			sourceTree = "<group>";
 		};
+		424204D920C6150A005AEED9 /* QRCode */ = {
+			isa = PBXGroup;
+			children = (
+				424204DA20C61561005AEED9 /* RAQRCodeScannerViewController.h */,
+				424204DB20C61561005AEED9 /* RAQRCodeScannerViewController.m */,
+				424204DD20C6156E005AEED9 /* QRCode.storyboard */,
+			);
+			path = QRCode;
+			sourceTree = "<group>";
+		};
+		424204DF20C657EE005AEED9 /* Camera */ = {
+			isa = PBXGroup;
+			children = (
+				424204E520C668AE005AEED9 /* RATakePhotoPreviewController.h */,
+				424204E620C668AE005AEED9 /* RATakePhotoPreviewController.m */,
+				424204E020C65817005AEED9 /* RACameraViewController.h */,
+				424204E120C65817005AEED9 /* RACameraViewController.m */,
+				424204E320C65827005AEED9 /* Camera.storyboard */,
+			);
+			path = Camera;
+			sourceTree = "<group>";
+		};
+		424204EB20C66CFE005AEED9 /* PhotoPreView */ = {
+			isa = PBXGroup;
+			children = (
+				424204EC20C66D20005AEED9 /* RAPhotoPreviewController.h */,
+				424204ED20C66D20005AEED9 /* RAPhotoPreviewController.m */,
+				424204EF20C66D2D005AEED9 /* PhotoPreview.storyboard */,
+			);
+			path = PhotoPreView;
+			sourceTree = "<group>";
+		};
 		42529D1E20C0E8C4000C0F4D /* Network */ = {
 			isa = PBXGroup;
 			children = (
@@ -348,6 +404,10 @@
 				42529D2A20C0EA0A000C0F4D /* RAUtils.m */,
 				4205FD5620C0F6F100DB42B4 /* RAConvertor.h */,
 				4205FD5720C0F6F100DB42B4 /* RAConvertor.m */,
+				424204F120C68E02005AEED9 /* RAProgressHUD.h */,
+				424204F220C68E02005AEED9 /* RAProgressHUD.m */,
+				424204E820C6698A005AEED9 /* UIImage+fixOrientation.h */,
+				424204E920C6698A005AEED9 /* UIImage+fixOrientation.m */,
 			);
 			name = Utils;
 			sourceTree = "<group>";
@@ -579,6 +639,9 @@
 				42D8B8A420C23D69001C125F /* Detail */,
 				42D8B8A520C23D75001C125F /* Update */,
 				42D8B8A120C224EE001C125F /* FakeData */,
+				424204D920C6150A005AEED9 /* QRCode */,
+				424204DF20C657EE005AEED9 /* Camera */,
+				424204EB20C66CFE005AEED9 /* PhotoPreView */,
 				71EAA33120B9571B002F003C /* AppDelegate.h */,
 				71EAA33220B9571B002F003C /* AppDelegate.m */,
 				4205FD5D20C134B400DB42B4 /* Other */,
@@ -655,10 +718,13 @@
 				4255EC8220C51A5000E5DA24 /* Barcode_n.png in Resources */,
 				4255ECA120C5400400E5DA24 /* Barcode_h.png in Resources */,
 				42D8B8A320C2253E001C125F /* fake_order_list.json in Resources */,
+				424204E420C65827005AEED9 /* Camera.storyboard in Resources */,
 				42D8B8E020C28755001C125F /* fake_order_detail.json in Resources */,
 				71EAA33B20B95720002F003C /* Assets.xcassets in Resources */,
 				42D8B8AA20C23DF0001C125F /* Detail.storyboard in Resources */,
 				4255EC8F20C5260400E5DA24 /* fake_order_edit.json in Resources */,
+				424204DE20C6156E005AEED9 /* QRCode.storyboard in Resources */,
+				424204F020C66D2D005AEED9 /* PhotoPreview.storyboard in Resources */,
 				4280034220C0F146004D4F50 /* LICENSE in Resources */,
 				4255EC7620C5097200E5DA24 /* Edit.storyboard in Resources */,
 				4205FD6320C136F900DB42B4 /* Home.storyboard in Resources */,
@@ -674,8 +740,10 @@
 			isa = PBXSourcesBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				424204EA20C6698A005AEED9 /* UIImage+fixOrientation.m in Sources */,
 				4255EC8720C51D4900E5DA24 /* RAEditPhotoCell.m in Sources */,
 				4280034520C0F146004D4F50 /* NSString+Base64.m in Sources */,
+				424204F320C68E02005AEED9 /* RAProgressHUD.m in Sources */,
 				42D8B8BF20C24A92001C125F /* RADetailSingleLineModel.m in Sources */,
 				42D8B8D820C273AC001C125F /* RADetailActionsCell+CollectionViewDataSource.m in Sources */,
 				42529D3B20C0EA3F000C0F4D /* unzip.c in Sources */,
@@ -688,6 +756,8 @@
 				42529D2120C0E8EC000C0F4D /* NetworkUtils.m in Sources */,
 				42D8B8CF20C2657D001C125F /* RADetailBaseModel.m in Sources */,
 				4205FD5520C0F50C00DB42B4 /* JLPresentationController.m in Sources */,
+				424204E220C65817005AEED9 /* RACameraViewController.m in Sources */,
+				424204EE20C66D20005AEED9 /* RAPhotoPreviewController.m in Sources */,
 				42529D3D20C0EA3F000C0F4D /* ZipArchive.mm in Sources */,
 				4280034320C0F146004D4F50 /* NSData+Base64.m in Sources */,
 				42D8B8C820C24B0B001C125F /* RADetailActionCollectionModel.m in Sources */,
@@ -713,7 +783,9 @@
 				42D8B8B120C2462D001C125F /* RADetailMultLineCell.m in Sources */,
 				4280034120C0F146004D4F50 /* AESCrypt.m in Sources */,
 				42529D2520C0E97E000C0F4D /* RADataProvider.m in Sources */,
+				424204DC20C61561005AEED9 /* RAQRCodeScannerViewController.m in Sources */,
 				42D8B8D520C27399001C125F /* RADetailActionsCell+CollectionViewDelegate.m in Sources */,
+				424204E720C668AE005AEED9 /* RATakePhotoPreviewController.m in Sources */,
 				4205FD6C20C13E0700DB42B4 /* RAHomeViewController+HomeTableDelegate.m in Sources */,
 				4255EC9F20C5287D00E5DA24 /* RAEditPhotoModel.m in Sources */,
 				4205FD5420C0F50C00DB42B4 /* JLCustomerNavigationAlertController.m in Sources */,
@@ -881,6 +953,7 @@
 				GCC_PRECOMPILE_PREFIX_HEADER = YES;
 				GCC_PREFIX_HEADER = "$(SRCROOT)/Apex And Drivers/PrefixHeader.pch";
 				INFOPLIST_FILE = "Apex And Drivers/Info.plist";
+				IPHONEOS_DEPLOYMENT_TARGET = 10.0;
 				LD_RUNPATH_SEARCH_PATHS = (
 					"$(inherited)",
 					"@executable_path/Frameworks",
@@ -901,6 +974,7 @@
 				GCC_PRECOMPILE_PREFIX_HEADER = YES;
 				GCC_PREFIX_HEADER = "$(SRCROOT)/Apex And Drivers/PrefixHeader.pch";
 				INFOPLIST_FILE = "Apex And Drivers/Info.plist";
+				IPHONEOS_DEPLOYMENT_TARGET = 10.0;
 				LD_RUNPATH_SEARCH_PATHS = (
 					"$(inherited)",
 					"@executable_path/Frameworks",

+ 148 - 0
Redant Drivers/Apex And Drivers/Camera/Camera.storyboard

@@ -0,0 +1,148 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14109" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
+    <device id="retina4_7" orientation="portrait">
+        <adaptation id="fullscreen"/>
+    </device>
+    <dependencies>
+        <deployment identifier="iOS"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14088"/>
+        <capability name="Safe area layout guides" minToolsVersion="9.0"/>
+        <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
+    </dependencies>
+    <scenes>
+        <!--Camera View Controller-->
+        <scene sceneID="4sG-sz-uXW">
+            <objects>
+                <viewController storyboardIdentifier="RACameraViewController" useStoryboardIdentifierAsRestorationIdentifier="YES" id="u3G-8E-Sj8" customClass="RACameraViewController" sceneMemberID="viewController">
+                    <view key="view" contentMode="scaleToFill" id="ZFi-1H-xB4">
+                        <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
+                        <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+                        <subviews>
+                            <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="aIR-II-sqh">
+                                <rect key="frame" x="0.0" y="20" width="375" height="647"/>
+                                <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
+                            </view>
+                            <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="2cM-nE-ueF">
+                                <rect key="frame" x="0.0" y="20" width="375" height="647"/>
+                                <subviews>
+                                    <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Zmb-bI-WjK">
+                                        <rect key="frame" x="144.5" y="517" width="85" height="30"/>
+                                        <state key="normal" title="Take Picture"/>
+                                        <connections>
+                                            <action selector="takePictureBtnClick:" destination="u3G-8E-Sj8" eventType="touchUpInside" id="1LX-1e-klr"/>
+                                        </connections>
+                                    </button>
+                                </subviews>
+                                <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
+                                <constraints>
+                                    <constraint firstAttribute="bottom" secondItem="Zmb-bI-WjK" secondAttribute="bottom" constant="100" id="f8Y-IT-5Vo"/>
+                                    <constraint firstItem="Zmb-bI-WjK" firstAttribute="centerX" secondItem="2cM-nE-ueF" secondAttribute="centerX" id="wR7-zz-eVK"/>
+                                </constraints>
+                            </view>
+                        </subviews>
+                        <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
+                        <constraints>
+                            <constraint firstItem="fLT-zm-dh6" firstAttribute="bottom" secondItem="2cM-nE-ueF" secondAttribute="bottom" id="9Y0-7J-sXY"/>
+                            <constraint firstItem="fLT-zm-dh6" firstAttribute="trailing" secondItem="aIR-II-sqh" secondAttribute="trailing" id="CZh-X5-9Zr"/>
+                            <constraint firstItem="2cM-nE-ueF" firstAttribute="leading" secondItem="fLT-zm-dh6" secondAttribute="leading" id="Igd-YW-xgj"/>
+                            <constraint firstItem="fLT-zm-dh6" firstAttribute="bottom" secondItem="aIR-II-sqh" secondAttribute="bottom" id="bSC-7H-ATA"/>
+                            <constraint firstItem="2cM-nE-ueF" firstAttribute="top" secondItem="fLT-zm-dh6" secondAttribute="top" id="fox-Pf-jXw"/>
+                            <constraint firstItem="aIR-II-sqh" firstAttribute="top" secondItem="fLT-zm-dh6" secondAttribute="top" id="iNS-Ag-rc8"/>
+                            <constraint firstItem="fLT-zm-dh6" firstAttribute="trailing" secondItem="2cM-nE-ueF" secondAttribute="trailing" id="plK-cA-ZV1"/>
+                            <constraint firstItem="aIR-II-sqh" firstAttribute="leading" secondItem="fLT-zm-dh6" secondAttribute="leading" id="yWd-lg-8xz"/>
+                        </constraints>
+                        <viewLayoutGuide key="safeArea" id="fLT-zm-dh6"/>
+                    </view>
+                    <connections>
+                        <outlet property="controlContanier" destination="2cM-nE-ueF" id="8g4-KY-DMK"/>
+                        <outlet property="previewContainer" destination="aIR-II-sqh" id="Xhl-yB-wfI"/>
+                    </connections>
+                </viewController>
+                <placeholder placeholderIdentifier="IBFirstResponder" id="65S-tr-YKy" userLabel="First Responder" sceneMemberID="firstResponder"/>
+            </objects>
+            <point key="canvasLocation" x="-23" y="161"/>
+        </scene>
+        <!--Take Photo Preview Controller-->
+        <scene sceneID="Y0T-nH-52O">
+            <objects>
+                <viewController storyboardIdentifier="RATakePhotoPreviewController" automaticallyAdjustsScrollViewInsets="NO" useStoryboardIdentifierAsRestorationIdentifier="YES" id="hfm-f2-DNT" customClass="RATakePhotoPreviewController" sceneMemberID="viewController">
+                    <layoutGuides>
+                        <viewControllerLayoutGuide type="top" id="JtE-cJ-OW0"/>
+                        <viewControllerLayoutGuide type="bottom" id="1aO-Vd-AQh"/>
+                    </layoutGuides>
+                    <view key="view" contentMode="scaleToFill" id="khP-jm-wId">
+                        <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
+                        <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+                        <subviews>
+                            <scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" showsHorizontalScrollIndicator="NO" showsVerticalScrollIndicator="NO" maximumZoomScale="4" translatesAutoresizingMaskIntoConstraints="NO" id="w4v-z1-b7B">
+                                <rect key="frame" x="0.0" y="20" width="375" height="647"/>
+                                <connections>
+                                    <outlet property="delegate" destination="hfm-f2-DNT" id="0Kg-98-liP"/>
+                                </connections>
+                            </scrollView>
+                            <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Xpx-fL-Mis">
+                                <rect key="frame" x="1" y="110" width="373" height="395"/>
+                            </view>
+                            <view alpha="0.44999998807907104" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="WfP-Fk-mo9">
+                                <rect key="frame" x="0.0" y="605" width="375" height="62"/>
+                                <subviews>
+                                    <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="XlI-8n-qRu">
+                                        <rect key="frame" x="20" y="16" width="47" height="30"/>
+                                        <fontDescription key="fontDescription" type="system" pointSize="15"/>
+                                        <state key="normal" title="Retake"/>
+                                        <connections>
+                                            <action selector="retakeBtnClick:" destination="hfm-f2-DNT" eventType="touchUpInside" id="7eA-Kj-Zq8"/>
+                                        </connections>
+                                    </button>
+                                    <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="ZBU-jX-GTo">
+                                        <rect key="frame" x="283" y="16" width="72" height="30"/>
+                                        <fontDescription key="fontDescription" type="system" pointSize="15"/>
+                                        <state key="normal" title="Use Photo"/>
+                                        <connections>
+                                            <action selector="usePhotoClick:" destination="hfm-f2-DNT" eventType="touchUpInside" id="3JY-Vk-Gu3"/>
+                                        </connections>
+                                    </button>
+                                </subviews>
+                                <color key="backgroundColor" white="0.33333333329999998" alpha="1" colorSpace="calibratedWhite"/>
+                                <constraints>
+                                    <constraint firstItem="ZBU-jX-GTo" firstAttribute="centerY" secondItem="WfP-Fk-mo9" secondAttribute="centerY" id="IPi-1Q-dac"/>
+                                    <constraint firstItem="XlI-8n-qRu" firstAttribute="leading" secondItem="WfP-Fk-mo9" secondAttribute="leading" constant="20" id="PQS-SF-GaW"/>
+                                    <constraint firstAttribute="trailing" secondItem="ZBU-jX-GTo" secondAttribute="trailing" constant="20" id="bwu-A0-IZQ"/>
+                                    <constraint firstAttribute="height" constant="62" id="cnn-ba-VJB"/>
+                                    <constraint firstItem="XlI-8n-qRu" firstAttribute="centerY" secondItem="WfP-Fk-mo9" secondAttribute="centerY" id="gCx-yd-g3m"/>
+                                </constraints>
+                            </view>
+                        </subviews>
+                        <color key="backgroundColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
+                        <constraints>
+                            <constraint firstItem="1aO-Vd-AQh" firstAttribute="top" secondItem="WfP-Fk-mo9" secondAttribute="bottom" id="18i-Al-Ypd"/>
+                            <constraint firstItem="WfP-Fk-mo9" firstAttribute="leading" secondItem="khP-jm-wId" secondAttribute="leading" id="MSv-jh-Kws"/>
+                            <constraint firstItem="Xpx-fL-Mis" firstAttribute="leading" secondItem="khP-jm-wId" secondAttribute="leading" constant="1" id="PGU-Bl-cae"/>
+                            <constraint firstItem="1aO-Vd-AQh" firstAttribute="top" secondItem="w4v-z1-b7B" secondAttribute="bottom" id="ZV0-ao-dGH"/>
+                            <constraint firstItem="Xpx-fL-Mis" firstAttribute="top" secondItem="JtE-cJ-OW0" secondAttribute="bottom" constant="90" id="a6t-MS-egk"/>
+                            <constraint firstAttribute="trailing" secondItem="Xpx-fL-Mis" secondAttribute="trailing" constant="1" id="an8-dn-WXn"/>
+                            <constraint firstItem="w4v-z1-b7B" firstAttribute="leading" secondItem="khP-jm-wId" secondAttribute="leading" id="eWS-j0-eyB"/>
+                            <constraint firstItem="WfP-Fk-mo9" firstAttribute="top" secondItem="Xpx-fL-Mis" secondAttribute="bottom" constant="100" id="oIh-uh-DBC"/>
+                            <constraint firstAttribute="trailing" secondItem="w4v-z1-b7B" secondAttribute="trailing" id="qYR-pg-xfY"/>
+                            <constraint firstItem="w4v-z1-b7B" firstAttribute="top" secondItem="JtE-cJ-OW0" secondAttribute="bottom" id="vBb-3e-ld9"/>
+                            <constraint firstAttribute="trailing" secondItem="WfP-Fk-mo9" secondAttribute="trailing" id="wKB-RK-2W0"/>
+                        </constraints>
+                        <viewLayoutGuide key="safeArea" id="BrA-yF-F9H"/>
+                    </view>
+                    <nil key="simulatedStatusBarMetrics"/>
+                    <nil key="simulatedTopBarMetrics"/>
+                    <nil key="simulatedBottomBarMetrics"/>
+                    <connections>
+                        <outlet property="editContainer" destination="Xpx-fL-Mis" id="el8-Dl-ZdA"/>
+                        <outlet property="previewScroll" destination="w4v-z1-b7B" id="mvQ-nK-wZW"/>
+                        <outlet property="retakeBtn" destination="XlI-8n-qRu" id="Og5-TY-dJU"/>
+                        <outlet property="toolBarView" destination="WfP-Fk-mo9" id="sdI-yW-TCC"/>
+                        <outlet property="usePhotoBtn" destination="ZBU-jX-GTo" id="c0Y-4b-GQ9"/>
+                    </connections>
+                </viewController>
+                <placeholder placeholderIdentifier="IBFirstResponder" id="ex0-03-0bJ" userLabel="First Responder" sceneMemberID="firstResponder"/>
+            </objects>
+            <point key="canvasLocation" x="2557.5999999999999" y="243.32833583208398"/>
+        </scene>
+    </scenes>
+</document>

+ 17 - 0
Redant Drivers/Apex And Drivers/Camera/RACameraViewController.h

@@ -0,0 +1,17 @@
+//
+//  RACameraViewController.h
+//  Apex And Drivers
+//
+//  Created by Jack on 2018/6/5.
+//  Copyright © 2018年 USAI. All rights reserved.
+//
+
+#import "RABaseViewController.h"
+
+@interface RACameraViewController : RABaseViewController
+
+@property (nonatomic,copy) void (^completion)(UIImage *image);
+
+@property (nonatomic,weak) UIViewController *fromVC;
+
+@end

+ 201 - 0
Redant Drivers/Apex And Drivers/Camera/RACameraViewController.m

@@ -0,0 +1,201 @@
+//
+//  RACameraViewController.m
+//  Apex And Drivers
+//
+//  Created by Jack on 2018/6/5.
+//  Copyright © 2018年 USAI. All rights reserved.
+//
+
+#import "RACameraViewController.h"
+#import <AVFoundation/AVFoundation.h>
+#import "RATakePhotoPreviewController.h"
+
+@interface RACameraViewController ()
+
+@property (nonatomic,strong) IBOutlet UIView *previewContainer;
+@property (nonatomic,strong) IBOutlet UIView *controlContanier;
+
+#pragma mark - Camera
+
+@property (nonatomic,strong) AVCaptureDevice *captureDevice;
+@property (nonatomic,strong) AVCaptureSession *captureSession;
+@property (nonatomic,strong) AVCaptureDeviceInput *captureInput;
+@property (nonatomic,strong) AVCaptureStillImageOutput *captureOutput;
+@property (nonatomic,strong) AVCaptureVideoPreviewLayer *previewLayer;
+
+@end
+
+@implementation RACameraViewController
+
++ (instancetype)viewControllerFromStoryboard {
+    RACameraViewController *cameraVC = [[UIStoryboard storyboardWithName:@"Camera" bundle:nil] instantiateViewControllerWithIdentifier:[self storyboardID]];
+    return cameraVC;
+}
+
+- (void)viewDidLoad {
+    [super viewDidLoad];
+    // Do any additional setup after loading the view.
+    
+    [self initCapture];
+    [self initTakePicture];
+}
+
+- (void)didReceiveMemoryWarning {
+    [super didReceiveMemoryWarning];
+    // Dispose of any resources that can be recreated.
+}
+
+- (void)viewWillAppear:(BOOL)animated {
+    [super viewWillAppear:animated];
+    
+    [self.captureSession startRunning];
+}
+
+- (void)viewWillDisappear:(BOOL)animated {
+    [super viewWillDisappear:animated];
+    
+    if ([self.captureSession isRunning]) {
+        [self.captureSession stopRunning];
+    }
+}
+
+- (void)viewDidLayoutSubviews {
+    [super viewDidLayoutSubviews];
+    
+    self.previewLayer.frame = self.previewContainer.bounds;
+}
+
+#pragma mark - Capture
+
+- (void)initCapture {
+    
+    self.captureSession = [[AVCaptureSession alloc] init];
+    
+    self.captureDevice = [self videoDevicePosition:AVCaptureDevicePositionBack];
+    if (!self.captureDevice) {
+        return;
+    }
+    
+    NSError *error;
+    self.captureInput = [[AVCaptureDeviceInput alloc] initWithDevice:self.captureDevice error:&error];
+    
+    [self.captureSession beginConfiguration];
+    
+    if ([_captureSession canSetSessionPreset:AVCaptureSessionPresetHigh]) {
+        _captureSession.sessionPreset = AVCaptureSessionPresetHigh;
+    }
+    
+    if ([self.captureSession canAddInput:self.captureInput]) {
+        
+        
+        [self.captureSession addInput:self.captureInput];
+        
+//        if ([self.captureSession canSetSessionPreset:AVCaptureSessionPreset1920x1080]) {
+//            self.captureSession.sessionPreset = AVCaptureSessionPreset1920x1080;
+//        } else {
+//            if ([self.captureSession canSetSessionPreset:AVCaptureSessionPresetHigh]) {
+//                self.captureSession.sessionPreset = AVCaptureSessionPresetHigh;
+//            }
+//        }
+        
+    }
+    
+    [self.captureSession commitConfiguration];
+    
+    self.previewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:self.captureSession];
+    self.previewLayer.videoGravity = AVLayerVideoGravityResizeAspectFill;
+    [self.previewContainer.layer addSublayer:self.previewLayer];
+}
+
+- (void)initTakePicture {
+    
+    self.captureOutput = [[AVCaptureStillImageOutput alloc] init];
+    AVCaptureConnection *connection = [self.captureOutput connectionWithMediaType:AVMediaTypeVideo];
+    if (connection.supportsVideoOrientation) {
+        connection.videoOrientation = [self.previewLayer connection].videoOrientation;
+//        connection.videoOrientation = [self captureVideoOrientation];
+    }
+    
+    NSDictionary *setting = @{AVVideoCodecKey:AVVideoCodecJPEG};
+    [self.captureOutput setOutputSettings:setting];
+    
+    if ([self.captureSession canAddOutput:self.captureOutput]) {
+        [self.captureSession addOutput:self.captureOutput];
+    }
+
+}
+
+- (AVCaptureDevice *) videoDevicePosition:(AVCaptureDevicePosition)position {
+
+    NSArray *videoDevices = [AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo];
+    for (AVCaptureDevice *device in videoDevices) {
+        if ([device position] == position) {
+            return device;
+        }
+    }
+    
+    return nil;
+}
+
+- (AVCaptureVideoOrientation)captureVideoOrientation {
+    AVCaptureVideoOrientation result;
+    
+    UIDeviceOrientation deviceOrientation = [UIDevice currentDevice].orientation;
+    switch (deviceOrientation) {
+        case UIDeviceOrientationPortrait:
+        case UIDeviceOrientationFaceUp:
+        case UIDeviceOrientationFaceDown:
+            result = AVCaptureVideoOrientationPortrait;
+            break;
+        case UIDeviceOrientationPortraitUpsideDown:
+            //如果这里设置成AVCaptureVideoOrientationPortraitUpsideDown,则视频方向和拍摄时的方向是相反的。
+            result = AVCaptureVideoOrientationPortrait;
+            break;
+        case UIDeviceOrientationLandscapeLeft:
+            result = AVCaptureVideoOrientationLandscapeRight;
+            break;
+        case UIDeviceOrientationLandscapeRight:
+            result = AVCaptureVideoOrientationLandscapeLeft;
+            break;
+        default:
+            result = AVCaptureVideoOrientationPortrait;
+            break;
+    }
+    
+    return result;
+}
+
+#pragma mark - Action
+
+- (IBAction)takePictureBtnClick:(UIButton *)sender {
+    
+    AVCaptureConnection *connection = [self.captureOutput connectionWithMediaType:AVMediaTypeVideo];
+    [self.captureOutput captureStillImageAsynchronouslyFromConnection:connection completionHandler:^(CMSampleBufferRef  _Nullable imageDataSampleBuffer, NSError * _Nullable error) {
+        
+        if (imageDataSampleBuffer) {
+            NSData *imageData=[AVCaptureStillImageOutput jpegStillImageNSDataRepresentation:imageDataSampleBuffer];
+            UIImage *image=[UIImage imageWithData:imageData];
+            
+            __weak typeof(self) weakSelf = self;
+            RATakePhotoPreviewController *preVC = [RATakePhotoPreviewController viewControllerFromStoryboard];
+            preVC.photoHandler = ^(UIImage *img){
+                if (weakSelf) {
+                    __strong typeof(weakSelf) strongSelf = weakSelf;
+                    if (strongSelf.completion) {
+                        strongSelf.completion(img);
+                    }
+                }
+            };
+            preVC.preImage = image;
+            preVC.popTo = self.fromVC;
+            [self.navigationController pushViewController:preVC animated:YES];
+            
+        } else {
+            NSLog(@"take picture failed: %@",error);
+        }
+        
+    }];
+}
+
+
+@end

+ 19 - 0
Redant Drivers/Apex And Drivers/Camera/RATakePhotoPreviewController.h

@@ -0,0 +1,19 @@
+//
+//  TakePhotoPreviewController.h
+//  RA Image
+//
+//  Created by Jack on 2017/5/15.
+//  Copyright © 2017年 USAI. All rights reserved.
+//
+
+#import "RABaseViewController.h"
+
+@interface RATakePhotoPreviewController : RABaseViewController
+
+@property (nonatomic,strong) UIImage *preImage;
+
+@property (nonatomic,copy) void(^photoHandler) (UIImage *);
+
+@property (nonatomic,weak) UIViewController *popTo;
+
+@end

+ 268 - 0
Redant Drivers/Apex And Drivers/Camera/RATakePhotoPreviewController.m

@@ -0,0 +1,268 @@
+//
+//  TakePhotoPreviewController.m
+//  RA Image
+//
+//  Created by Jack on 2017/5/15.
+//  Copyright © 2017年 USAI. All rights reserved.
+//
+
+#import "RATakePhotoPreviewController.h"
+#import "const.h"
+#import "UIImage+fixOrientation.h"
+
+@interface RATakePhotoPreviewController ()<UIScrollViewDelegate>
+
+@property (strong, nonatomic) IBOutlet UIScrollView *previewScroll;
+@property (strong, nonatomic) IBOutlet UIView *editContainer;
+@property (strong, nonatomic) IBOutlet UIButton *retakeBtn;
+@property (strong, nonatomic) IBOutlet UIButton *usePhotoBtn;
+@property (strong, nonatomic) IBOutlet UIView *toolBarView;
+
+@property (nonatomic,strong) UIImageView *imgView;
+
+@end
+
+@implementation RATakePhotoPreviewController
+
++ (instancetype)viewControllerFromStoryboard {
+    RATakePhotoPreviewController *previewVC = [[UIStoryboard storyboardWithName:@"Camera" bundle:nil] instantiateViewControllerWithIdentifier:[self storyboardID]];
+    return previewVC;
+}
+
+- (void)viewDidLoad {
+    [super viewDidLoad];
+    // Do any additional setup after loading the view.
+    [self.view insertSubview:[UIView new] atIndex:0];
+    
+    self.editContainer.layer.borderColor = [UIColor lightGrayColor].CGColor;
+    self.editContainer.layer.borderWidth = 0.5f;
+    self.editContainer.userInteractionEnabled = NO;
+//    UIPinchGestureRecognizer *pinch = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(imageViewPinch:)];
+//    [self.editContainer addGestureRecognizer:pinch];
+    
+    
+    [self.previewScroll addSubview:self.imgView];
+}
+- (void)setPreImage:(UIImage *)preImage {
+    _preImage = [preImage fixOrientation];
+    //    self.nameLabel.text = name;
+}
+- (void)viewDidLayoutSubviews {
+    [super viewDidLayoutSubviews];
+    
+    CGSize size = [self imgViewOriginSize];
+    
+    CGRect frame = CGRectMake(0, 70, size.width, size.height); // 水平居中
+    
+    if (frame.size.height < CGRectGetHeight(self.editContainer.frame)) { // 横屏拍照时,照片在编辑框垂直居中
+        frame.origin.y = CGRectGetMinY(self.editContainer.frame) + (CGRectGetHeight(self.editContainer.frame) - CGRectGetHeight(frame)) * 0.5;
+    }
+    self.imgView.frame = frame;
+}
+
+- (BOOL)prefersStatusBarHidden {
+    return YES;
+}
+
+- (void)didReceiveMemoryWarning {
+    [super didReceiveMemoryWarning];
+    // Dispose of any resources that can be recreated.
+}
+
+- (CGSize)imgViewOriginSize {
+    CGFloat width = CGRectGetWidth(self.previewScroll.bounds);
+    CGFloat height = CGRectGetHeight(self.previewScroll.bounds);
+    CGFloat w = self.preImage.size.width;
+    CGFloat h = self.preImage.size.height;
+    // 根据图片大小和ScrollView大小等比缩放,使ScrollView容得下图片
+    float factor = MAX(w / width, h / height);
+    factor = 1 / factor;
+    
+    CGSize size = CGSizeMake(w * factor, h * factor);
+    return size;
+}
+
+- (UIImageView *)imgView {
+    if (!_imgView) {
+        _imgView = [[UIImageView alloc] initWithImage:self.preImage];
+        _imgView.userInteractionEnabled = YES;
+        
+    }
+    return _imgView;
+}
+
+- (UIImage *)captureImageInView:(UIView *)view {
+    UIImage *img = nil;
+    
+//    UIGraphicsBeginImageContext(view.frame.size);
+    UIGraphicsBeginImageContextWithOptions(view.frame.size, NO, 0.0);
+    if ([view respondsToSelector:@selector(drawViewHierarchyInRect:afterScreenUpdates:)]) {
+        [view drawViewHierarchyInRect:view.bounds afterScreenUpdates:YES];
+    } else {
+        [view.layer renderInContext:UIGraphicsGetCurrentContext()];
+    }
+    img = UIGraphicsGetImageFromCurrentImageContext();
+    UIGraphicsEndImageContext();
+    
+    return img;
+}
+
+- (UIImage *)captureImageWithImage:(UIImage *)image inRect:(CGRect)rect {
+    
+    CGFloat scale = image.scale;
+    rect.origin.x *= scale;
+    rect.origin.y *= scale;
+    rect.size.height *= scale;
+    rect.size.width *= scale;
+    CGImageRef imgRef = CGImageCreateWithImageInRect(image.CGImage, rect);
+    UIImage *img = [UIImage imageWithCGImage:imgRef scale:0 orientation:image.imageOrientation];
+    CGImageRelease(imgRef);
+    return img;
+    
+    
+    
+}
+
+- (IBAction)retakeBtnClick:(UIButton *)sender {
+    if (self.photoHandler) {
+        self.photoHandler(nil);
+    }
+    [self.navigationController popViewControllerAnimated:YES];
+}
+
+- (IBAction)usePhotoClick:(UIButton *)sender {
+    
+    if (self.photoHandler) {
+        
+        CGRect imgRect = self.imgView.frame;
+        CGRect editRect = self.editContainer.frame;
+        CGPoint contentOffset = self.previewScroll.contentOffset;
+        CGRect clipRect = CGRectMake(editRect.origin.x + 1 + contentOffset.x, editRect.origin.y + 1 + contentOffset.y - imgRect.origin.y, editRect.size.width - 2, editRect.size.height -2);
+        
+        CGFloat xp = clipRect.origin.x / imgRect.size.width;
+        CGFloat yp = clipRect.origin.y / imgRect.size.height;
+        CGFloat wp = clipRect.size.width / imgRect.size.width;
+        CGFloat hp = clipRect.size.height / imgRect.size.height;
+        
+        CGSize size = self.preImage.size;
+        CGRect clipImgRect = CGRectMake(size.width * xp, size.height * yp, size.width * wp, size.height * hp);
+        
+        UIImage *img = [self captureImageWithImage:self.preImage inRect:clipImgRect];
+        self.photoHandler(img);
+    }
+    if (self.popTo) {
+        [self.navigationController popToViewController:self.popTo animated:YES];
+    } else {
+        [self.navigationController popViewControllerAnimated:YES];
+    }
+    
+}
+
+//-(void) testimg
+//{
+//    UIImageOrientation o =self.preImage.imageOrientation;
+//    
+//    CGRect imgviewRect = self.imgView.frame;
+//    CGRect editRect = self.editContainer.frame;
+//    CGPoint offset= self.previewScroll.contentOffset;
+//    
+//    double sscale=self.previewScroll.zoomScale;
+//    CGSize contentsize=self.previewScroll.contentSize;
+//    
+//    CGRect imgScreenRect = CGRectMake(imgviewRect.origin.x-offset.x, imgviewRect.origin.y-offset.y, imgviewRect.size.width, imgviewRect.size.height);
+//    
+//    double scale = imgScreenRect.size.width/self.preImage.size.width;//1;//self.previewScroll.zoomScale*(imgviewRect.size.width/self.preImage.size.width);
+//    CGRect rectimg = CGRectMake((editRect.origin.x-imgScreenRect.origin.x)/scale, (editRect.origin.y-imgScreenRect.origin.y)/scale, editRect.size.width/scale, editRect.size.height/scale);
+////    UIImage * newimg=[UIImage imageWithCGImage:self.preImage.CGImage scale:1 orientation:UIImageOrientationUp];
+//    UIImage * img= [self captureImageWithImage:self.preImage inRect:rectimg];//
+//    UIImage* img1 =[self getSubImage:rectimg img:self.preImage];
+//    return;
+//}
+//
+//
+//-(UIImage*)getSubImage:(CGRect)rect img:(UIImage*)img
+//{
+//    
+//    //将UIImage转换成CGImageRef
+//    CGImageRef sourceImageRef = [img CGImage];
+//    
+//    //按照给定的矩形区域进行剪裁
+//    CGImageRef newImageRef = CGImageCreateWithImageInRect(sourceImageRef, rect);
+//    
+//    //将CGImageRef转换成UIImage
+//    UIImage *newImage = [UIImage imageWithCGImage:newImageRef];
+//    
+//    //返回剪裁后的图片
+//    return newImage;
+//    
+//    
+//    CGImageRef subImageRef = CGImageCreateWithImageInRect(img.CGImage, rect);
+//    UIImage* debugimg = [UIImage imageWithCGImage:subImageRef];
+//    CGRect smallBounds = CGRectMake(0, 0, CGImageGetWidth(subImageRef), CGImageGetHeight(subImageRef));
+//    
+//    UIGraphicsBeginImageContext(smallBounds.size);
+//    CGContextRef context = UIGraphicsGetCurrentContext();
+//    CGContextDrawImage(context, smallBounds, subImageRef);
+//    UIImage* smallImage = [UIImage imageWithCGImage:subImageRef];
+//    UIGraphicsEndImageContext();
+//    
+//    return smallImage;
+//}
+#pragma mark - UIScrollViewDelegate
+
+- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView {
+    return self.imgView;
+}
+
+- (void)scrollViewDidZoom:(UIScrollView *)scrollView {
+    
+    CGRect imgRect = self.imgView.frame;
+    CGSize contentSize = scrollView.contentSize;
+    contentSize.height += imgRect.origin.y;
+    scrollView.contentSize = contentSize;
+}
+
+//#pragma mark - pinch
+//
+//- (void)imageViewPinch:(UIPinchGestureRecognizer *)pinch{
+//    
+//    UIScrollView *scroll = self.previewScroll;
+//    UIImageView *imgv = [scroll.subviews firstObject];
+//    
+//    CGFloat width = scroll.frame.size.width;
+//    CGFloat height = scroll.frame.size.height;
+//    
+//    imgv.transform = CGAffineTransformScale(imgv.transform, pinch.scale, pinch.scale);
+//    CGSize size = scroll.contentSize;
+//    //    size.width = size.width * pinch.scale;
+//    //    size.height = size.height * pinch.scale;
+//    size = imgv.frame.size;// bounds 和 frame 不一致
+//    CGSize itemSize = self.editContainer.frame.size;
+//    DebugLog(@"size %@",[NSValue valueWithCGSize:size]);
+//    if (size.height < itemSize.height || size.width < itemSize.width) { // 禁止缩小得比原图小
+//        imgv.transform = CGAffineTransformIdentity;
+//        size = imgv.frame.size;
+//    }
+//    
+//    
+////    if (size.width < width) {
+////        size.width = width;
+////    }
+////    if (size.height < height) {
+////        size.height = height;
+////    }
+//    
+//    scroll.contentSize = size;
+//    scroll.contentOffset = CGPointMake((size.width - width) * 0.5, (size.height - height) * 0.5);
+//    // 保持在屏幕中心
+//    CGPoint offset = scroll.contentOffset;
+//    CGFloat x = offset.x + width * 0.5;
+//    CGFloat y = offset.y + height * 0.5;
+//    imgv.center = CGPointMake(x, y);
+//    
+//    pinch.scale = 1;
+//}
+
+
+
+@end

+ 2 - 0
Redant Drivers/Apex And Drivers/Detail/Action Selection/RADetailActionSelectionModel.h

@@ -13,4 +13,6 @@
 @property (nonatomic,copy) NSString *actionTitle;
 @property (nonatomic,assign) NSInteger actionID;
 
+@property (nonatomic,copy) NSString *detailActionTitle; // 用于EditVC.title
+
 @end

+ 1 - 0
Redant Drivers/Apex And Drivers/Detail/Model/Collection/RADetailActionModel.m

@@ -23,6 +23,7 @@
         NSDictionary *enumDic = [tmpEnums objectAtIndex:i];
         RADetailActionSelectionModel *model = [[RADetailActionSelectionModel alloc] init];
         [model setValuesForKeysWithDictionary:enumDic];
+        model.detailActionTitle = self.actionTitle;
         [modelArr addObject:model];
     }
     _enums = modelArr;

+ 1 - 1
Redant Drivers/Apex And Drivers/Detail/RAOrderDetailViewController+TableViewDataSource.m

@@ -185,7 +185,7 @@
     RAOrderEditViewController *vc = [RAOrderEditViewController viewControllerFromStoryboard];
 //    RAOrderEditViewController *vc = [[RAOrderEditViewController alloc] init]; // 使用代码直接创建,在Push动画过程中会卡一下,具体原因不明
 
-    vc.title = @"Update Action";
+    vc.title = model.detailActionTitle;
     vc.orderID = self.orderID;
     vc.actionID = model.actionID;
     [self.navigationController pushViewController:vc animated:YES];

+ 2 - 0
Redant Drivers/Apex And Drivers/Home/RAHomeViewController.m

@@ -9,6 +9,7 @@
 #import "RAHomeViewController.h"
 #import "RAHomeOrderModel.h"
 #import "RAOrderDetailViewController.h"
+#import "RAProgressHUD.h"
 
 @interface RAHomeSectionModel : NSObject
 
@@ -110,6 +111,7 @@
 - (void)loadData {
     
     // show progress
+//    RAProgressHUD *hud = [RAProgressHUD showHUDOnView:self.view];
     
     __weak typeof(self) weakSelf = self;
     dispatch_async(dispatch_get_global_queue(0, 0), ^{

+ 14 - 0
Redant Drivers/Apex And Drivers/Info.plist

@@ -45,5 +45,19 @@
 	<array>
 		<string>comgooglemaps</string>
 	</array>
+	<key>NSCameraUsageDescription</key>
+	<string>need use camera</string>
+    <key>NSLocationWhenInUseUsageDescription</key>
+    <string>tracking deliver status</string>
+    <key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
+    <string>tracking deliver status</string>
+    <key>NSLocationAlwaysUsageDescription</key>
+    <string>tracking deliver status</string>
+    <key>NSLocationUsageDescription</key>
+    <string>show loaction on map </string>
+    <key>UIBackgroundModes</key>
+    <array>
+        <string>location</string>
+    </array>
 </dict>
 </plist>

+ 60 - 0
Redant Drivers/Apex And Drivers/PhotoPreView/PhotoPreview.storyboard

@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14109" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
+    <device id="retina4_7" orientation="portrait">
+        <adaptation id="fullscreen"/>
+    </device>
+    <dependencies>
+        <deployment identifier="iOS"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14088"/>
+        <capability name="Safe area layout guides" minToolsVersion="9.0"/>
+        <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
+    </dependencies>
+    <scenes>
+        <!--Photo Preview Controller-->
+        <scene sceneID="eEs-Qi-Z9g">
+            <objects>
+                <viewController storyboardIdentifier="RAPhotoPreviewController" useStoryboardIdentifierAsRestorationIdentifier="YES" id="RVI-dc-c8o" customClass="RAPhotoPreviewController" sceneMemberID="viewController">
+                    <view key="view" contentMode="scaleToFill" id="Put-gL-uFK">
+                        <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
+                        <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+                        <subviews>
+                            <scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" maximumZoomScale="3" translatesAutoresizingMaskIntoConstraints="NO" id="NSD-S6-RMq">
+                                <rect key="frame" x="0.0" y="20" width="375" height="647"/>
+                                <subviews>
+                                    <imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="Boj-uR-XZO">
+                                        <rect key="frame" x="0.0" y="0.0" width="375" height="647"/>
+                                    </imageView>
+                                </subviews>
+                                <constraints>
+                                    <constraint firstItem="Boj-uR-XZO" firstAttribute="top" secondItem="NSD-S6-RMq" secondAttribute="top" id="Irc-7R-UA3"/>
+                                    <constraint firstItem="Boj-uR-XZO" firstAttribute="width" secondItem="NSD-S6-RMq" secondAttribute="width" id="MlN-j3-AbU"/>
+                                    <constraint firstItem="Boj-uR-XZO" firstAttribute="height" secondItem="NSD-S6-RMq" secondAttribute="height" id="XZ4-ZT-Luv"/>
+                                    <constraint firstAttribute="trailing" secondItem="Boj-uR-XZO" secondAttribute="trailing" id="aO4-Jn-BKu"/>
+                                    <constraint firstItem="Boj-uR-XZO" firstAttribute="leading" secondItem="NSD-S6-RMq" secondAttribute="leading" id="dHR-3O-niC"/>
+                                    <constraint firstAttribute="bottom" secondItem="Boj-uR-XZO" secondAttribute="bottom" id="ud5-Ld-QSC"/>
+                                </constraints>
+                                <connections>
+                                    <outlet property="delegate" destination="RVI-dc-c8o" id="tYS-hd-STa"/>
+                                </connections>
+                            </scrollView>
+                        </subviews>
+                        <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
+                        <constraints>
+                            <constraint firstItem="NSD-S6-RMq" firstAttribute="leading" secondItem="uoF-bN-Ts9" secondAttribute="leading" id="69J-WI-iDO"/>
+                            <constraint firstItem="uoF-bN-Ts9" firstAttribute="trailing" secondItem="NSD-S6-RMq" secondAttribute="trailing" id="fp0-hh-vln"/>
+                            <constraint firstItem="uoF-bN-Ts9" firstAttribute="bottom" secondItem="NSD-S6-RMq" secondAttribute="bottom" id="pjC-8d-QEv"/>
+                            <constraint firstItem="NSD-S6-RMq" firstAttribute="top" secondItem="uoF-bN-Ts9" secondAttribute="top" id="rP9-b1-NWJ"/>
+                        </constraints>
+                        <viewLayoutGuide key="safeArea" id="uoF-bN-Ts9"/>
+                    </view>
+                    <connections>
+                        <outlet property="photoImageView" destination="Boj-uR-XZO" id="JWR-Qd-tPb"/>
+                        <outlet property="photoScrollView" destination="NSD-S6-RMq" id="i1l-61-uOd"/>
+                    </connections>
+                </viewController>
+                <placeholder placeholderIdentifier="IBFirstResponder" id="zRN-Tv-SjT" userLabel="First Responder" sceneMemberID="firstResponder"/>
+            </objects>
+            <point key="canvasLocation" x="71" y="37"/>
+        </scene>
+    </scenes>
+</document>

+ 17 - 0
Redant Drivers/Apex And Drivers/PhotoPreView/RAPhotoPreviewController.h

@@ -0,0 +1,17 @@
+//
+//  RAPhotoPreviewController.h
+//  Apex And Drivers
+//
+//  Created by Jack on 2018/6/5.
+//  Copyright © 2018年 USAI. All rights reserved.
+//
+
+#import "RABaseViewController.h"
+
+@interface RAPhotoPreviewController : RABaseViewController
+
+@property (nonatomic,strong) UIImage *image;
+
+@property (nonatomic,copy) void (^completion)(void);
+
+@end

+ 74 - 0
Redant Drivers/Apex And Drivers/PhotoPreView/RAPhotoPreviewController.m

@@ -0,0 +1,74 @@
+//
+//  RAPhotoPreviewController.m
+//  Apex And Drivers
+//
+//  Created by Jack on 2018/6/5.
+//  Copyright © 2018年 USAI. All rights reserved.
+//
+
+#import "RAPhotoPreviewController.h"
+
+@interface RAPhotoPreviewController () <UIScrollViewDelegate>
+
+@property (strong, nonatomic) IBOutlet UIImageView *photoImageView;
+@property (strong, nonatomic) IBOutlet UIScrollView *photoScrollView;
+
+
+@end
+
+@implementation RAPhotoPreviewController
+
++ (instancetype)viewControllerFromStoryboard {
+    RAPhotoPreviewController *previewVC = [[UIStoryboard storyboardWithName:@"PhotoPreview" bundle:nil] instantiateViewControllerWithIdentifier:[self storyboardID]];
+    return previewVC;
+}
+
+- (void)viewDidLoad {
+    [super viewDidLoad];
+    // Do any additional setup after loading the view.
+    
+    self.photoImageView.image = self.image;
+    [self configureNavigationBar];
+}
+
+- (void)didReceiveMemoryWarning {
+    [super didReceiveMemoryWarning];
+    // Dispose of any resources that can be recreated.
+}
+
+- (void)configureNavigationBar {
+    
+    UIBarButtonItem *deleteItem = [[UIBarButtonItem alloc] initWithTitle:@"delete" style:UIBarButtonItemStylePlain target:self action:@selector(deleteActionClick:)];
+    self.navigationItem.rightBarButtonItem = deleteItem;
+    
+}
+
+#pragma mark - Action
+
+- (void)deleteActionClick:(UIBarButtonItem *)sender {
+    
+    UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:nil message:@"Are you sure you want to delete it" preferredStyle:UIAlertControllerStyleAlert];
+    __weak typeof(self) weakSelf = self;
+    UIAlertAction *yesAction = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
+        if (weakSelf.completion) {
+            weakSelf.completion();
+        }
+        [weakSelf.navigationController popViewControllerAnimated:YES];
+    }];
+    UIAlertAction *noAction = [UIAlertAction actionWithTitle:@"No" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
+        
+    }];
+    
+    [alertVC addAction:noAction];
+    [alertVC addAction:yesAction];
+    
+    [self presentViewController:alertVC animated:YES completion:nil];
+}
+
+#pragma mark - Scroll Delegate
+
+- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView {
+    return self.photoImageView;
+}
+
+@end

+ 71 - 0
Redant Drivers/Apex And Drivers/QRCode/QRCode.storyboard

@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14109" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
+    <device id="retina4_7" orientation="portrait">
+        <adaptation id="fullscreen"/>
+    </device>
+    <dependencies>
+        <deployment identifier="iOS"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14088"/>
+        <capability name="Aspect ratio constraints" minToolsVersion="5.1"/>
+        <capability name="Safe area layout guides" minToolsVersion="9.0"/>
+        <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
+    </dependencies>
+    <scenes>
+        <!--Code Scanner View Controller-->
+        <scene sceneID="SCd-VM-Uux">
+            <objects>
+                <viewController storyboardIdentifier="RAQRCodeScannerViewController" useStoryboardIdentifierAsRestorationIdentifier="YES" id="41J-NQ-wiU" customClass="RAQRCodeScannerViewController" sceneMemberID="viewController">
+                    <view key="view" contentMode="scaleToFill" id="aiT-qZ-M5f">
+                        <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
+                        <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+                        <subviews>
+                            <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="D8z-rA-Qpf">
+                                <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
+                                <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
+                            </view>
+                            <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="vCI-Zm-N7X">
+                                <rect key="frame" x="70" y="146" width="235" height="235"/>
+                                <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
+                                <constraints>
+                                    <constraint firstAttribute="width" secondItem="vCI-Zm-N7X" secondAttribute="height" multiplier="1:1" id="8cj-iq-wvr"/>
+                                </constraints>
+                            </view>
+                            <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="0ig-dn-iSa">
+                                <rect key="frame" x="169.5" y="567" width="35" height="30"/>
+                                <state key="normal" title="Scan"/>
+                                <state key="highlighted" title="Scanning"/>
+                                <connections>
+                                    <action selector="scannerBtnTouchCancel:" destination="41J-NQ-wiU" eventType="touchCancel" id="z40-QN-qDW"/>
+                                    <action selector="scannerBtnTouchDown:" destination="41J-NQ-wiU" eventType="touchDown" id="5TK-sG-LzS"/>
+                                    <action selector="scannerBtnTouchUp:" destination="41J-NQ-wiU" eventType="touchUpInside" id="Nco-1e-gQv"/>
+                                    <action selector="scannerBtnTouchUpOutSide:" destination="41J-NQ-wiU" eventType="touchUpOutside" id="O42-nG-qkE"/>
+                                </connections>
+                            </button>
+                        </subviews>
+                        <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
+                        <constraints>
+                            <constraint firstItem="0ig-dn-iSa" firstAttribute="top" relation="greaterThanOrEqual" secondItem="vCI-Zm-N7X" secondAttribute="bottom" constant="10" id="3gR-v0-uuY"/>
+                            <constraint firstItem="vCI-Zm-N7X" firstAttribute="centerX" secondItem="TEW-wV-M4S" secondAttribute="centerX" id="8dy-2H-2iw"/>
+                            <constraint firstItem="D8z-rA-Qpf" firstAttribute="width" secondItem="aiT-qZ-M5f" secondAttribute="width" id="BuV-2a-gda"/>
+                            <constraint firstItem="D8z-rA-Qpf" firstAttribute="leading" secondItem="aiT-qZ-M5f" secondAttribute="leading" id="RYY-iZ-sc1"/>
+                            <constraint firstItem="0ig-dn-iSa" firstAttribute="centerX" secondItem="TEW-wV-M4S" secondAttribute="centerX" id="bkm-1o-EpZ"/>
+                            <constraint firstItem="TEW-wV-M4S" firstAttribute="trailing" secondItem="vCI-Zm-N7X" secondAttribute="trailing" constant="70" id="cSr-ne-Xxd"/>
+                            <constraint firstItem="vCI-Zm-N7X" firstAttribute="centerY" secondItem="TEW-wV-M4S" secondAttribute="centerY" constant="-80" id="fNO-9Q-eMD"/>
+                            <constraint firstItem="vCI-Zm-N7X" firstAttribute="leading" secondItem="TEW-wV-M4S" secondAttribute="leading" constant="70" id="ncF-ii-QJ5"/>
+                            <constraint firstItem="TEW-wV-M4S" firstAttribute="bottom" secondItem="0ig-dn-iSa" secondAttribute="bottom" constant="70" id="qin-xY-VOb"/>
+                            <constraint firstItem="D8z-rA-Qpf" firstAttribute="top" secondItem="aiT-qZ-M5f" secondAttribute="top" id="rVq-z9-u0f"/>
+                            <constraint firstItem="D8z-rA-Qpf" firstAttribute="height" secondItem="aiT-qZ-M5f" secondAttribute="height" id="swA-T5-xSR"/>
+                        </constraints>
+                        <viewLayoutGuide key="safeArea" id="TEW-wV-M4S"/>
+                    </view>
+                    <connections>
+                        <outlet property="previewContainer" destination="D8z-rA-Qpf" id="XCg-1T-zSa"/>
+                        <outlet property="scanerView" destination="vCI-Zm-N7X" id="09n-Fn-vIF"/>
+                    </connections>
+                </viewController>
+                <placeholder placeholderIdentifier="IBFirstResponder" id="3tF-Yn-TdS" userLabel="First Responder" sceneMemberID="firstResponder"/>
+            </objects>
+            <point key="canvasLocation" x="-154" y="162"/>
+        </scene>
+    </scenes>
+</document>

+ 15 - 0
Redant Drivers/Apex And Drivers/QRCode/RAQRCodeScannerViewController.h

@@ -0,0 +1,15 @@
+//
+//  RAQRCodeScannerViewController.h
+//  Apex And Drivers
+//
+//  Created by Jack on 2018/6/5.
+//  Copyright © 2018年 USAI. All rights reserved.
+//
+
+#import "RABaseViewController.h"
+
+@interface RAQRCodeScannerViewController : RABaseViewController
+
+@property (nonatomic,copy) void (^completion)(NSString *value);
+
+@end

+ 188 - 0
Redant Drivers/Apex And Drivers/QRCode/RAQRCodeScannerViewController.m

@@ -0,0 +1,188 @@
+//
+//  RAQRCodeScannerViewController.m
+//  Apex And Drivers
+//
+//  Created by Jack on 2018/6/5.
+//  Copyright © 2018年 USAI. All rights reserved.
+//
+
+#import "RAQRCodeScannerViewController.h"
+#import <AVKit/AVKit.h>
+
+@interface RAQRCodeScannerViewController () <AVCaptureMetadataOutputObjectsDelegate>
+
+@property (strong, nonatomic) IBOutlet UIView *scanerView;
+@property (nonatomic,strong) IBOutlet UIView *previewContainer;
+
+@property (nonatomic,strong) AVCaptureDevice *device;
+@property (nonatomic,strong) AVCaptureDeviceInput *input;
+@property (nonatomic,strong) AVCaptureMetadataOutput *output;
+@property (nonatomic,strong) AVCaptureSession *session;
+@property (nonatomic,strong) AVCaptureVideoPreviewLayer *previewLayer;
+
+@property (nonatomic,assign) BOOL scannerEnable;
+@property (nonatomic,strong) CAGradientLayer *scanLineLayer;
+
+@end
+
+@implementation RAQRCodeScannerViewController
+
++ (instancetype)viewControllerFromStoryboard {
+    RAQRCodeScannerViewController *scannerVC = [[UIStoryboard storyboardWithName:@"QRCode" bundle:nil] instantiateViewControllerWithIdentifier:[self storyboardID]];
+    return scannerVC;
+}
+
+- (void)viewDidLoad {
+    [super viewDidLoad];
+    // Do any additional setup after loading the view.
+    
+    self.scanerView.layer.borderColor = [UIColor blackColor].CGColor;
+    self.scanerView.layer.borderWidth = 0.5f;
+    
+    [self initCapture];
+}
+
+- (void)viewDidLayoutSubviews {
+    [super viewDidLayoutSubviews];
+    
+    self.previewLayer.frame = self.view.bounds;
+    
+    CGFloat w = CGRectGetWidth(self.view.bounds);
+    CGFloat h = CGRectGetHeight(self.view.bounds);
+    
+    /**
+     rectOfInterest 都是按照横屏来计算的 所以当竖屏的情况下 x轴和y轴要交换一下
+     否则在竖屏下不能扫描条形码。
+     */
+    CGRect rect = CGRectMake(CGRectGetMinY(self.scanerView.frame) / h, CGRectGetMinX(self.scanerView.frame) / w, CGRectGetHeight(self.scanerView.frame) / h, CGRectGetWidth(self.scanerView.frame) / w);
+    
+    [self.output setRectOfInterest:rect];
+    
+    [self.view bringSubviewToFront:self.scanerView];
+    
+    CGRect scanlineFrame = CGRectMake(0, CGRectGetMidY(self.scanerView.bounds) - 0.5, CGRectGetWidth(self.scanerView.bounds), 1);
+    self.scanLineLayer.frame = scanlineFrame;
+    [self.scanerView.layer insertSublayer:self.scanLineLayer atIndex:0];
+}
+
+- (void)viewDidAppear:(BOOL)animated {
+    [super viewDidAppear:animated];
+    
+    [self.session startRunning];
+}
+
+- (void)viewWillDisappear:(BOOL)animated {
+    [super viewWillDisappear:animated];
+    
+    [self.session stopRunning];
+}
+
+- (void)didReceiveMemoryWarning {
+    [super didReceiveMemoryWarning];
+    // Dispose of any resources that can be recreated.
+}
+
+- (CAGradientLayer *)scanLineLayer {
+    if (!_scanLineLayer) {
+        CAGradientLayer *gradientLayer = [CAGradientLayer layer];
+        //set gradient colors
+        // 数组成员接受 CGColorRef 类型的值
+        gradientLayer.colors = @[(__bridge id)[UIColor colorWithRed:1 green:0 blue:0 alpha:0.2].CGColor,(__bridge id)[UIColor redColor].CGColor,(__bridge id)[UIColor colorWithRed:1 green:0 blue:0 alpha:0.2].CGColor];
+        
+        gradientLayer.locations = @[@2.5,@0.5,@0.75];
+
+        gradientLayer.startPoint = CGPointMake(0, 0);
+        gradientLayer.endPoint = CGPointMake(1, 0);
+        _scanLineLayer = gradientLayer;
+    }
+    return _scanLineLayer;
+}
+
+#pragma mark - Init
+
+- (void)initCapture {
+        
+    self.device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
+    
+    NSError *inputError;
+    self.input = [AVCaptureDeviceInput deviceInputWithDevice:self.device error:&inputError];
+    
+    if (inputError) {
+     
+        return;
+    }
+    
+    self.session = [[AVCaptureSession alloc] init];
+    [self.session setSessionPreset:AVCaptureSessionPresetHigh];
+    if ([self.session canAddInput:self.input]) {
+        [self.session addInput:self.input];
+    } else {
+        return;
+    }
+    
+    self.output = [[AVCaptureMetadataOutput alloc] init];
+    [self.output setMetadataObjectsDelegate:self queue:dispatch_get_main_queue()];
+    
+    if ([self.session canAddOutput:self.output]) {
+        [self.session addOutput:self.output];
+    } else {
+        return;
+    }
+    self.output.metadataObjectTypes = @[
+                                        AVMetadataObjectTypeQRCode,
+                                        AVMetadataObjectTypeEAN13Code,
+                                        AVMetadataObjectTypeEAN8Code,
+                                        AVMetadataObjectTypeUPCECode,
+                                        AVMetadataObjectTypeCode39Code,
+                                        AVMetadataObjectTypeCode39Mod43Code,
+                                        AVMetadataObjectTypeCode93Code,
+                                        AVMetadataObjectTypeCode128Code,
+                                        AVMetadataObjectTypePDF417Code
+                                        ];
+    
+    self.previewLayer = [AVCaptureVideoPreviewLayer layerWithSession:self.session];
+    self.previewLayer.videoGravity = AVLayerVideoGravityResizeAspectFill;
+    [self.previewContainer.layer addSublayer:self.previewLayer];
+    
+}
+
+#pragma mark - AVCaptureMetadataOutputObjectsDelegate
+
+- (void)captureOutput:(AVCaptureOutput *)output didOutputMetadataObjects:(NSArray<__kindof AVMetadataObject *> *)metadataObjects fromConnection:(AVCaptureConnection *)connection {
+    
+    if (!self.scannerEnable) {
+        return;
+    }
+    
+    if ([metadataObjects count] > 0) {
+        [self.session stopRunning];
+        
+        AVMetadataMachineReadableCodeObject *metadataObject = [metadataObjects objectAtIndex:0];
+        NSString *codeValue = metadataObject.stringValue;
+        if (self.completion) {
+            self.completion(codeValue);
+        }
+        [self.navigationController popViewControllerAnimated:YES];
+    }
+    
+}
+
+#pragma mark - Action
+
+- (IBAction)scannerBtnTouchDown:(UIButton *)sender {
+    self.scannerEnable = YES;
+}
+
+- (IBAction)scannerBtnTouchUp:(UIButton *)sender {
+    self.scannerEnable = NO;
+}
+
+- (IBAction)scannerBtnTouchUpOutSide:(UIButton *)sender {
+    self.scannerEnable = NO;
+}
+
+- (IBAction)scannerBtnTouchCancel:(UIButton *)sender {
+    self.scannerEnable = NO;
+}
+
+@end

+ 17 - 0
Redant Drivers/Apex And Drivers/RAProgressHUD.h

@@ -0,0 +1,17 @@
+//
+//  RAProgressHUD.h
+//  Apex And Drivers
+//
+//  Created by Jack on 2018/6/5.
+//  Copyright © 2018年 USAI. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+@interface RAProgressHUD : UIView
+
++ (instancetype)showHUDOnView:(UIView *)view;
+
+- (void)dismiss;
+
+@end

+ 70 - 0
Redant Drivers/Apex And Drivers/RAProgressHUD.m

@@ -0,0 +1,70 @@
+//
+//  RAProgressHUD.m
+//  Apex And Drivers
+//
+//  Created by Jack on 2018/6/5.
+//  Copyright © 2018年 USAI. All rights reserved.
+//
+
+#import "RAProgressHUD.h"
+
+@implementation RAProgressHUD
+
++ (instancetype)showHUDOnView:(UIView *)view {
+    
+    if (!view) {
+        return nil;
+    }
+    
+    RAProgressHUD *hud = [[RAProgressHUD alloc] init];
+    CGFloat viewWidth = CGRectGetWidth(view.bounds);
+    CGFloat viewHeight = CGRectGetHeight(view.bounds);
+    
+//    CGRect frame = CGRectMake((viewWidth - 100) * 0.5, (viewHeight - 100) * 0.5, 100, 100);
+//    hud.frame = frame;
+    hud.backgroundColor = [UIColor lightGrayColor];
+    hud.layer.cornerRadius = 5.0f;
+    hud.layer.masksToBounds = YES;
+    [view addSubview:hud];
+    
+    hud.translatesAutoresizingMaskIntoConstraints = NO;
+    
+    NSLayoutConstraint *h_center = [NSLayoutConstraint constraintWithItem:hud
+                                                                attribute:NSLayoutAttributeCenterX
+                                                                relatedBy:NSLayoutRelationEqual
+                                                                   toItem:view
+                                                                attribute:NSLayoutAttributeCenterX
+                                                               multiplier:1
+                                                                 constant:0];
+    
+    NSLayoutConstraint *v_center = [NSLayoutConstraint constraintWithItem:hud
+                                                                attribute:NSLayoutAttributeCenterY
+                                                                relatedBy:NSLayoutRelationEqual
+                                                                   toItem:view
+                                                                attribute:NSLayoutAttributeCenterY
+                                                               multiplier:1
+                                                                 constant:0];
+    NSLayoutConstraint *width = [NSLayoutConstraint constraintWithItem:hud
+                                                                attribute:NSLayoutAttributeWidth
+                                                                relatedBy:NSLayoutRelationEqual
+                                                                   toItem:nil
+                                                                attribute:NSLayoutAttributeNotAnAttribute
+                                                               multiplier:0
+                                                                 constant:100];
+    NSLayoutConstraint *height = [NSLayoutConstraint constraintWithItem:hud
+                                                             attribute:NSLayoutAttributeHeight
+                                                             relatedBy:NSLayoutRelationEqual
+                                                                toItem:nil
+                                                             attribute:NSLayoutAttributeNotAnAttribute
+                                                            multiplier:0
+                                                              constant:100];
+    [view addConstraints:@[h_center,v_center,width,height]];
+    
+    return hud;
+}
+
+- (void)dismiss {
+    [self removeFromSuperview];
+}
+
+@end

+ 16 - 1
Redant Drivers/Apex And Drivers/Update/Cell/RAEditMultInputCell.m

@@ -9,7 +9,7 @@
 #import "RAEditMultInputCell.h"
 #import "RAEditMultInputModel.h"
 
-@interface RAEditMultInputCell () <UITextViewDelegate>
+@interface RAEditMultInputCell () <UITextViewDelegate,RAEditModelDelegate>
 
 @property (strong, nonatomic) IBOutlet UILabel *titleLabel;
 @property (strong, nonatomic) IBOutlet UITextView *inputView;
@@ -43,8 +43,19 @@
 }
 
 - (void)setModel:(RAEditMultInputModel *)model {
+    if (_model) {
+        _model.delegate = nil;
+    }
     _model = model;
     
+    _model.delegate = self;
+    
+    [self refresh];
+}
+
+#pragma mark - Model Delegate
+
+- (void)refresh {
     self.titleLabel.text = _model.title;
     self.inputView.text = _model.value;
 }
@@ -69,4 +80,8 @@
     return YES;
 }
 
+- (void)textViewDidChange:(UITextView *)textView {
+    [self.model updateValue:textView.text];
+}
+
 @end

+ 9 - 1
Redant Drivers/Apex And Drivers/Update/Cell/RAEditPhotoCell.h

@@ -8,9 +8,17 @@
 
 #import <UIKit/UIKit.h>
 
-@class RAEditPhotoModel;
+@class RAEditPhotoModel,RAEditPhotoCell;
+
+@protocol RAEditPhotoCellDelegate <NSObject>
+
+- (void)photoCellWillOpenCameraOrShowPhoto:(RAEditPhotoCell *)cell;
+
+@end
+
 @interface RAEditPhotoCell : UITableViewCell
 
 @property (nonatomic,strong) RAEditPhotoModel *model;
+@property (nonatomic,weak) id<RAEditPhotoCellDelegate> delegate;
 
 @end

+ 19 - 8
Redant Drivers/Apex And Drivers/Update/Cell/RAEditPhotoCell.m

@@ -9,7 +9,7 @@
 #import "RAEditPhotoCell.h"
 #import "RAEditPhotoModel.h"
 
-@interface RAEditPhotoCell ()
+@interface RAEditPhotoCell () <RAEditModelDelegate>
 
 @property (strong, nonatomic) IBOutlet UILabel *titleLabel;
 @property (strong, nonatomic) IBOutlet UIImageView *photoView;
@@ -36,6 +36,7 @@
     [super prepareForReuse];
     
     self.model = nil;
+    self.delegate = nil;
 }
 
 - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
@@ -45,20 +46,30 @@
 }
 
 - (void)setModel:(RAEditPhotoModel *)model {
+    
+    if (_model) {
+        _model.delegate = nil;
+    }
+    
     _model = model;
     
-    self.titleLabel.text = _model.title;
-    self.photoView.image = _model.photo;
+    _model.delegate = self;
+    
+    [self refresh];
 }
 
 - (void)photoViewTap:(UITapGestureRecognizer *)sender {
     
-    if (self.model.photo) {
-        
-    } else {
-        
+    if (self.delegate && [self.delegate respondsToSelector:@selector(photoCellWillOpenCameraOrShowPhoto:)]) {
+        [self.delegate photoCellWillOpenCameraOrShowPhoto:self];
     }
-    
+}
+
+#pragma mark - Model Delegate
+
+- (void)refresh {
+    self.titleLabel.text = _model.title;
+    self.photoView.image = _model.photo;
 }
 
 @end

+ 1 - 0
Redant Drivers/Apex And Drivers/Update/Cell/RAEditScanInputCell.h

@@ -15,6 +15,7 @@
 
 - (void)beginEditInputCell:(RAEditScanInputCell *)cell;
 - (void)endEditInputCell:(RAEditScanInputCell *)cell;
+- (void)scanInputCell:(RAEditScanInputCell *)cell clickScanButton:(UIButton *)sender;
 
 @end
 

+ 27 - 5
Redant Drivers/Apex And Drivers/Update/Cell/RAEditScanInputCell.m

@@ -9,7 +9,7 @@
 #import "RAEditScanInputCell.h"
 #import "RAEditInputModel.h"
 
-@interface RAEditScanInputCell () <UITextFieldDelegate>
+@interface RAEditScanInputCell () <UITextFieldDelegate,RAEditModelDelegate>
 
 @property (strong, nonatomic) IBOutlet UILabel *titlelabel;
 @property (strong, nonatomic) IBOutlet UITextField *inputTextField;
@@ -40,8 +40,26 @@
 }
 
 - (void)setModel:(RAEditInputModel *)model {
+    if (_model) {
+        _model.delegate = nil;
+    }
     _model = model;
     
+    _model.delegate = self;
+    
+    [self refresh];
+}
+
+- (void)scanBtnClick:(UIButton *)sender {
+    if (self.delegate && [self.delegate respondsToSelector:@selector(scanInputCell:clickScanButton:)]) {
+        [self.delegate scanInputCell:self clickScanButton:sender];
+    }
+}
+
+#pragma mark - Edit Model Delegate
+
+- (void)refresh {
+    
     self.titlelabel.text = _model.title;
     self.inputTextField.text = _model.value;
     if (_model.scannable) {
@@ -60,10 +78,6 @@
     }
 }
 
-- (void)scanBtnClick:(UIButton *)sender {
-    NSLog(@"scan click");
-}
-
 #pragma mark - TextField Delegate
 
 - (BOOL)textFieldShouldBeginEditing:(UITextField *)textField {
@@ -83,4 +97,12 @@
     return YES;
 }
 
+- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
+    
+    NSString *newStr = [textField.text stringByReplacingCharactersInRange:range withString:string];
+    [self.model updateValue:newStr];
+    
+    return YES;
+}
+
 @end

+ 8 - 0
Redant Drivers/Apex And Drivers/Update/Model/RAEditBaseModel.h

@@ -17,10 +17,18 @@ typedef enum {
     
 } RAEditType;
 
+@protocol RAEditModelDelegate <NSObject>
+
+- (void)refresh;
+
+@end
+
 @interface RAEditBaseModel : NSObject
 
 @property (nonatomic,assign) RAEditType type;
 @property (nonatomic,copy) NSString *title;
 @property (nonatomic,assign) CGFloat height;
 
+@property (nonatomic,weak) id<RAEditModelDelegate> delegate;
+
 @end

+ 8 - 0
Redant Drivers/Apex And Drivers/Update/Model/RAEditBaseModel.m

@@ -14,4 +14,12 @@
     
 }
 
+- (void)setTitle:(NSString *)title {
+    _title = title;
+    
+    if (self.delegate && [self.delegate respondsToSelector:@selector(refresh)]) {
+        [self.delegate refresh];
+    }
+}
+
 @end

+ 2 - 0
Redant Drivers/Apex And Drivers/Update/Model/RAEditInputModel.h

@@ -13,4 +13,6 @@
 @property (nonatomic,assign) BOOL scannable;
 @property (nonatomic,copy) NSString *value;
 
+- (void)updateValue:(NSString *)value;
+
 @end

+ 12 - 0
Redant Drivers/Apex And Drivers/Update/Model/RAEditInputModel.m

@@ -14,4 +14,16 @@
     return 70.0f;
 }
 
+- (void)setValue:(NSString *)value {
+    _value = value;
+    
+    if (self.delegate && [self.delegate respondsToSelector:@selector(refresh)]) {
+        [self.delegate refresh];
+    }
+}
+
+- (void)updateValue:(NSString *)value {
+    _value = value;
+}
+
 @end

+ 2 - 0
Redant Drivers/Apex And Drivers/Update/Model/RAEditMultInputModel.h

@@ -12,4 +12,6 @@
 
 @property (nonatomic,copy) NSString *value;
 
+- (void)updateValue:(NSString *)value;
+
 @end

+ 13 - 1
Redant Drivers/Apex And Drivers/Update/Model/RAEditMultInputModel.m

@@ -11,7 +11,19 @@
 @implementation RAEditMultInputModel
 
 - (CGFloat)height {
-    return 120.0f;
+    return 150.0f;
+}
+
+- (void)setValue:(NSString *)value {
+    _value = value;
+    
+    if (self.delegate && [self.delegate respondsToSelector:@selector(refresh)]) {
+        [self.delegate refresh];
+    }
+}
+
+- (void)updateValue:(NSString *)value {
+    _value = value;
 }
 
 @end

+ 13 - 0
Redant Drivers/Apex And Drivers/Update/Model/RAEditPhotoModel.m

@@ -14,5 +14,18 @@
     return 100.0f;
 }
 
+- (void)setPath:(NSString *)path {
+    _path = path;
+    if (self.delegate && [self.delegate respondsToSelector:@selector(refresh)]) {
+        [self.delegate refresh];
+    }
+}
+
+- (void)setPhoto:(UIImage *)photo {
+    _photo = photo;
+    if (self.delegate && [self.delegate respondsToSelector:@selector(refresh)]) {
+        [self.delegate refresh];
+    }
+}
 
 @end

+ 2 - 1
Redant Drivers/Apex And Drivers/Update/RAOrderEditViewController+TableDataSource.h

@@ -9,7 +9,8 @@
 #import "RAOrderEditViewController.h"
 #import "RAEditScanInputCell.h"
 #import "RAEditMultInputCell.h"
+#import "RAEditPhotoCell.h"
 
-@interface RAOrderEditViewController (TableDataSource) <UITableViewDataSource,RAEditInputDelegate,RAEditMultInputDelegate>
+@interface RAOrderEditViewController (TableDataSource) <UITableViewDataSource,RAEditInputDelegate,RAEditMultInputDelegate,RAEditPhotoCellDelegate>
 
 @end

+ 41 - 1
Redant Drivers/Apex And Drivers/Update/RAOrderEditViewController+TableDataSource.m

@@ -9,13 +9,17 @@
 #import "RAOrderEditViewController+TableDataSource.h"
 
 #import "RAEditLabelCell.h"
-#import "RAEditPhotoCell.h"
+
 
 #import "RAEditInputModel.h"
 #import "RAEditMultInputModel.h"
 #import "RAEditLabelModel.h"
 #import "RAEditPhotoModel.h"
 
+#import "RAQRCodeScannerViewController.h"
+#import "RACameraViewController.h"
+#import "RAPhotoPreviewController.h"
+
 @implementation RAOrderEditViewController (TableDataSource)
 
 - (nonnull UITableViewCell *)tableView:(nonnull UITableView *)tableView cellForRowAtIndexPath:(nonnull NSIndexPath *)indexPath {
@@ -57,6 +61,7 @@
             RAEditPhotoCell *cell = [tableView dequeueReusableCellWithIdentifier:@"RAEditPhotoCell" forIndexPath:indexPath];
             RAEditPhotoModel *photoModel = (RAEditPhotoModel *)model;
             cell.model = photoModel;
+            cell.delegate = self;
             
             return cell;
         }
@@ -78,8 +83,43 @@
     return [self editSectionCount];
 }
 
+#pragma mark - PhotoCell Delegate
+
+- (void)photoCellWillOpenCameraOrShowPhoto:(RAEditPhotoCell *)cell {
+    
+    if (cell.model.photo) {
+        
+        RAPhotoPreviewController *previewVC = [RAPhotoPreviewController viewControllerFromStoryboard];
+        previewVC.image = cell.model.photo;
+        previewVC.completion = ^{
+            cell.model.photo = nil;
+        };
+        [self.navigationController pushViewController:previewVC animated:YES];
+        
+    } else {
+        
+        RACameraViewController *cameraVC = [RACameraViewController viewControllerFromStoryboard];
+        cameraVC.completion = ^(UIImage *image) {
+            cell.model.photo = image;
+        };
+        cameraVC.fromVC = self;
+        [self.navigationController pushViewController:cameraVC animated:YES];
+    }
+}
+
 #pragma mark - Input Delegate
 
+- (void)scanInputCell:(RAEditScanInputCell *)cell clickScanButton:(UIButton *)sender {
+    
+    RAQRCodeScannerViewController *scanVC = [RAQRCodeScannerViewController viewControllerFromStoryboard];
+    
+    scanVC.completion = ^(NSString *value) {
+        cell.model.value = value;
+    };
+    
+    [self.navigationController pushViewController:scanVC animated:YES];
+}
+
 - (void)beginEditInputCell:(RAEditScanInputCell *)cell {
     self.editingIndexPath = [self indexPathForCell:cell];
 }

+ 64 - 1
Redant Drivers/Apex And Drivers/Update/RAOrderEditViewController.m

@@ -13,6 +13,8 @@
 #import "RAEditLabelModel.h"
 #import "RAEditPhotoModel.h"
 
+#import <MapKit/MapKit.h>
+
 @interface RAEditSectionModel : NSObject
 
 @property (nonatomic,strong) NSArray <RAEditBaseModel *> *items;
@@ -83,11 +85,14 @@
 
 #pragma mark - View Controller
 
-@interface RAOrderEditViewController ()
+@interface RAOrderEditViewController () <CLLocationManagerDelegate>
 
 @property (nonatomic,strong) IBOutlet UITableView *orderEditTableView;
 @property (nonatomic,strong) NSMutableArray *sectionArray;
 
+@property (nonatomic,strong) CLLocationManager *locationManager;
+@property (nonatomic,strong) CLLocation *currentLocation;
+
 
 @end
 
@@ -103,18 +108,21 @@
     // Do any additional setup after loading the view.
     
     [self configureTable];
+    [self configureNavigationBar];
     [self loadData];
 }
 
 - (void)viewWillAppear:(BOOL)animated {
     [super viewWillAppear:animated];
     
+    [self startLocation];
     [self registKeyboardListener];
 }
 
 - (void)viewWillDisappear:(BOOL)animated {
     [super viewWillDisappear:animated];
     
+    [self stopLocation];
     [self unregistKeyboardListener];
 }
 
@@ -123,12 +131,33 @@
     // Dispose of any resources that can be recreated.
 }
 
+#pragma mark - Configure
+
+- (void)startLocation {
+    self.locationManager = [[CLLocationManager alloc] init];
+    self.locationManager.delegate = self;
+    [self.locationManager requestWhenInUseAuthorization];
+    [self.locationManager startUpdatingLocation];
+    self.locationManager.desiredAccuracy = kCLLocationAccuracyBestForNavigation;//设置定位精度
+    self.locationManager.distanceFilter = 10;
+}
+
+- (void)stopLocation {
+    [self.locationManager stopUpdatingLocation];
+}
+
 - (void)configureTable {
     
     self.orderEditTableView.tableFooterView = [UIView new];
     self.orderEditTableView.separatorInset = UIEdgeInsetsMake(0, 0, 0, 0);
 }
 
+- (void)configureNavigationBar {
+    
+    UIBarButtonItem *updateItem = [[UIBarButtonItem alloc] initWithTitle:@"Update" style:UIBarButtonItemStylePlain target:self action:@selector(updateBtnClick:)];
+    self.navigationItem.rightBarButtonItem = updateItem;
+}
+
 - (void)registKeyboardListener {
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillChangeFrame:) name:UIKeyboardWillChangeFrameNotification object:nil];
 }
@@ -217,6 +246,9 @@
 - (IBAction)tapToResignFirstResponder:(UITapGestureRecognizer *)sender {
     
     [self.view endEditing:YES];
+}
+
+- (void)updateBtnClick:(UIBarButtonItem *)sender {
     
 }
 
@@ -236,4 +268,35 @@
     }
 }
 
+#pragma mark - LocationManager Delegate
+
+- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray<CLLocation *> *)locations {
+    if (locations.count) {
+        self.currentLocation = [locations lastObject];
+    }
+}
+
+- (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status {
+    
+    if (status == kCLAuthorizationStatusDenied) {
+        
+        UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"Warning" message:@"app need location,would you like to open it" preferredStyle:UIAlertControllerStyleAlert];
+        UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
+            NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
+            if ([[UIApplication sharedApplication]canOpenURL:url]) {
+                [[UIApplication sharedApplication]openURL:url options:@{} completionHandler:nil];
+            }
+            [self.navigationController popViewControllerAnimated:NO];
+        }];
+        UIAlertAction *noAction = [UIAlertAction actionWithTitle:@"No" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
+            
+        }];
+        
+        [alertVC addAction:noAction];
+        [alertVC addAction:okAction];
+        
+        [self presentViewController:alertVC animated:YES completion:nil];
+    }
+}
+
 @end