Răsfoiți Sursa

1.修改RA Image裁剪图片视图界面,使横屏模式下拍照时照片在编辑框垂直居中。
2.修改RA Image图片查看界面缩放方式。
3.修复RA Image横屏时打开相机Control位置不正确。
4.修改RA Image上传列表,解决滑动时数据错乱。

Pen Li 9 ani în urmă
părinte
comite
3dd2e59d33

BIN
RA Image/RA Image.xcodeproj/project.xcworkspace/xcuserdata/macmini1.xcuserdatad/UserInterfaceState.xcuserstate


+ 17 - 17
RA Image/RA Image.xcodeproj/xcuserdata/macmini1.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist

@@ -4,19 +4,13 @@
    version = "2.0">
    <Breakpoints>
       <BreakpointProxy
-         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+         BreakpointExtensionID = "Xcode.Breakpoint.ExceptionBreakpoint">
          <BreakpointContent
-            shouldBeEnabled = "No"
+            shouldBeEnabled = "Yes"
             ignoreCount = "0"
             continueAfterRunningActions = "No"
-            filePath = "RA Image/AppDelegate.m"
-            timestampString = "516504853.123127"
-            startingColumnNumber = "9223372036854775807"
-            endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "105"
-            endingLineNumber = "105"
-            landmarkName = "-saveUploadTasks"
-            landmarkType = "7">
+            scope = "0"
+            stopOnStyle = "0">
          </BreakpointContent>
       </BreakpointProxy>
       <BreakpointProxy
@@ -26,23 +20,29 @@
             ignoreCount = "0"
             continueAfterRunningActions = "No"
             filePath = "../common/upload/RAUploadManager.m"
-            timestampString = "516505979.754627"
+            timestampString = "516704766.310527"
             startingColumnNumber = "9223372036854775807"
             endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "153"
-            endingLineNumber = "153"
-            landmarkName = "-removeTask:"
+            startingLineNumber = "270"
+            endingLineNumber = "270"
+            landmarkName = "-saveTasks"
             landmarkType = "7">
          </BreakpointContent>
       </BreakpointProxy>
       <BreakpointProxy
-         BreakpointExtensionID = "Xcode.Breakpoint.ExceptionBreakpoint">
+         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
          <BreakpointContent
             shouldBeEnabled = "Yes"
             ignoreCount = "0"
             continueAfterRunningActions = "No"
-            scope = "0"
-            stopOnStyle = "0">
+            filePath = "../common/upload/RAUploadOperation.m"
+            timestampString = "516705917.843587"
+            startingColumnNumber = "9223372036854775807"
+            endingColumnNumber = "9223372036854775807"
+            startingLineNumber = "178"
+            endingLineNumber = "178"
+            landmarkName = "-filePath:"
+            landmarkType = "7">
          </BreakpointContent>
       </BreakpointProxy>
    </Breakpoints>

+ 64 - 29
RA Image/RA Image/BasicModeViewController.m

@@ -15,6 +15,9 @@
 #import "TakePhotoPreviewController.h"
 
 
+#pragma clang diagnostic push 
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+
 @interface BasicModeViewController ()<UITextFieldDelegate>
 
 @property (nonatomic,strong) UIImagePickerController *imgPicker;
@@ -160,6 +163,12 @@
     
     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;
@@ -406,41 +415,65 @@
         
         image = [info objectForKey:UIImagePickerControllerOriginalImage];
 //        [picker dismissViewControllerAnimated:YES completion:nil];
+        __weak typeof(self) weakself = self;
+        TakePhotoPreviewController *preVC = (TakePhotoPreviewController *)[self viewControllerInStoryboard:@"Mode" withId:@"TakePhotoPreviewController"];
+        __weak typeof(preVC) weakPreVC = preVC;
+        preVC.photoHandler = ^(UIImage *img){
+            if (img) {
+                dispatch_async(dispatch_get_global_queue(0, 0), ^{
+                    NSString *path = [weakself saveImage:img];
+                    dispatch_async(dispatch_get_main_queue(), ^{
+                        if (path) {// 保存成功
+                            [weakself receiveImage:img];
+                            NSString *md5 = [RAUtils md5WithFile:path];
+                            NSMutableDictionary *photoDic = @{
+                                                              @"photo" : img,
+                                                              @"check" : @(NO),
+                                                              @"file"  : [path lastPathComponent],
+                                                              @"md5"   : md5,
+                                                              @"path"  : path
+                                                              }.mutableCopy;
+                            [weakself.photos insertObject:photoDic atIndex:0];
+                            weakself.photoCount++;
+                        } else {
+                            [RAUtils message_alert:@"Save photo failed" title:@"Warning" controller:weakPreVC];
+                        }
+                    });
+                    
+                });
+            }
+        };
+        preVC.preImage = image;
+        [self.imgPicker pushViewController:preVC animated:YES];
         
     } else if (picker .sourceType == UIImagePickerControllerSourceTypePhotoLibrary) {
         
         image = [info objectForKey:UIImagePickerControllerOriginalImage];
         [picker dismissViewControllerAnimated:YES completion:nil];
-    }
-    __weak typeof(self) weakself = self;
-    TakePhotoPreviewController *preVC = (TakePhotoPreviewController *)[self viewControllerInStoryboard:@"Mode" withId:@"TakePhotoPreviewController"];
-    preVC.photoHandler = ^(UIImage *img){
-        if (img) {
-            dispatch_async(dispatch_get_global_queue(0, 0), ^{
-                NSString *path = [weakself saveImage:img];
-                dispatch_async(dispatch_get_main_queue(), ^{
-                    if (path) {// 保存成功
-                        [weakself receiveImage:img];
-                        NSString *md5 = [RAUtils md5WithFile:path];
-                        NSMutableDictionary *photoDic = @{
-                                                          @"photo" : img,
-                                                          @"check" : @(NO),
-                                                          @"file"  : [path lastPathComponent],
-                                                          @"md5"   : md5,
-                                                          @"path"  : path
-                                                          }.mutableCopy;
-                        [weakself.photos addObject:photoDic];
-                        weakself.photoCount++;
-                    } else {
-                        [RAUtils message_alert:@"Save photo failed" title:@"Warning" controller:weakself];
-                    }
-                });
-
+        dispatch_async(dispatch_get_global_queue(0, 0), ^{
+            NSString *path = [self saveImage:image];
+            dispatch_async(dispatch_get_main_queue(), ^{
+                if (path) {// 保存成功
+                    [self receiveImage:image];
+                    NSString *md5 = [RAUtils md5WithFile:path];
+                    NSMutableDictionary *photoDic = @{
+                                                      @"photo" : image,
+                                                      @"check" : @(NO),
+                                                      @"file"  : [path lastPathComponent],
+                                                      @"md5"   : md5,
+                                                      @"path"  : path
+                                                      }.mutableCopy;
+                    [self.photos insertObject:photoDic atIndex:0];
+                    self.photoCount++;
+                } else {
+                    [RAUtils message_alert:@"Save photo failed" title:@"Warning" controller:self];
+                }
             });
-        }
-    };
-    preVC.preImage = image;
-    [self.imgPicker pushViewController:preVC animated:YES];
+            
+        });
+        
+    }
+   
 }
 
 
@@ -464,3 +497,5 @@
 }
 
 @end
+
+#pragma clang diagnostic pop

+ 4 - 1
RA Image/RA Image/Mode.storyboard

@@ -797,7 +797,7 @@
                         <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="4" translatesAutoresizingMaskIntoConstraints="NO" id="BHi-a9-hom">
+                            <scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" showsHorizontalScrollIndicator="NO" showsVerticalScrollIndicator="NO" maximumZoomScale="4" translatesAutoresizingMaskIntoConstraints="NO" id="BHi-a9-hom">
                                 <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
                                 <connections>
                                     <outlet property="delegate" destination="533-wD-Chz" id="K2H-WI-nD1"/>
@@ -857,6 +857,9 @@
                     <connections>
                         <outlet property="editContainer" destination="ySP-Oj-Ybt" id="Oxq-tv-RdU"/>
                         <outlet property="previewScroll" destination="BHi-a9-hom" id="ZG5-gt-Nqd"/>
+                        <outlet property="retakeBtn" destination="aIO-Rg-abl" id="yn3-fD-362"/>
+                        <outlet property="toolBarView" destination="OPr-J2-wJK" id="1Zh-c1-jpR"/>
+                        <outlet property="usePhotoBtn" destination="Khf-Lc-MrL" id="gjr-eb-MHh"/>
                     </connections>
                 </viewController>
                 <placeholder placeholderIdentifier="IBFirstResponder" id="RP8-jW-gRB" userLabel="First Responder" sceneMemberID="firstResponder"/>

+ 40 - 3
RA Image/RA Image/PhotoPreviewController.m

@@ -8,6 +8,8 @@
 
 #import "PhotoPreviewController.h"
 
+//#define PinchZoom
+
 @interface PhotoPreviewController ()<UIScrollViewDelegate>
 
 @property (strong, nonatomic) IBOutlet UIScrollView *previewScroll;
@@ -69,7 +71,11 @@
         UIScrollView *sc = [[UIScrollView alloc] initWithFrame:frame];
         sc.tag = 1024 + i;
         sc.delegate = self;
-//        sc.maximumZoomScale = 5; // pinch手势不能设置此值
+#ifndef PinchZoom
+        sc.maximumZoomScale = 5; // pinch手势不能设置此值
+#endif
+        sc.showsVerticalScrollIndicator = NO;
+        sc.showsHorizontalScrollIndicator = NO;
         [self.previewScroll addSubview:sc];
 
         NSDictionary *item = [self.photos objectAtIndex:i];
@@ -87,9 +93,10 @@
         iv.userInteractionEnabled = YES;
         [sc addSubview:iv];
         sc.contentSize = sc.frame.size;
-        
+#ifdef PinchZoom
         UIPinchGestureRecognizer *pinch = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(imageViewPinch:)];
         [iv addGestureRecognizer:pinch];
+#endif
     }
     self.previewScroll.contentSize = CGSizeMake(self.photos.count * width, 0);
     self.previewScroll.contentOffset = CGPointMake(width * _currentIndex, 0);
@@ -113,13 +120,43 @@
         CGFloat x = scrollView.contentOffset.x / scrollView.frame.size.width;
         int idx = (int)x;
         if (idx == x) {
-            self.currentIndex = idx;
+            if (self.currentIndex != idx) {
+                // 先恢复前一个页面ContentSize到原始大小
+                UIScrollView *scroll = [self.previewScroll viewWithTag:1024 + self.currentIndex];
+                scroll.zoomScale = 1.0f;
+                // 然后在切换Index
+                self.currentIndex = idx;
+            }
         }
     } else {
         
     }
 }
 
+#ifndef PinchZoom
+- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView {
+    UIScrollView *scroll = [self.previewScroll viewWithTag:1024 + self.currentIndex];
+    if (scroll == scrollView) {
+        UIImageView *imgv = [scroll.subviews firstObject];
+        return imgv;
+    }
+    return nil;
+}
+
+- (void)scrollViewDidZoom:(UIScrollView *)scrollView {
+    UIScrollView *scroll = [self.previewScroll viewWithTag:1024 + self.currentIndex];
+    if (scroll == scrollView) {
+        CGFloat width = CGRectGetWidth(self.previewScroll.bounds);
+        CGFloat height = CGRectGetHeight(self.previewScroll.bounds);
+        CGSize itemSize = [self itemSize:self.currentIndex];
+        CGSize contentSize = scrollView.contentSize;
+        contentSize.width += (width - itemSize.width);
+        contentSize.height += (height - itemSize.height);
+        scrollView.contentSize = contentSize;
+    }
+}
+#endif
+
 #pragma mark - pinch
 
 - (void)imageViewPinch:(UIPinchGestureRecognizer *)pinch{

+ 107 - 112
RA Image/RA Image/TakePhotoPreviewController.m

@@ -14,6 +14,9 @@
 
 @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;
 
@@ -26,12 +29,13 @@
     // Do any additional setup after loading the view.
     [self.view insertSubview:[UIView new] atIndex:0];
     
-    self.editContainer.layer.borderColor = [UIColor whiteColor].CGColor;
+    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 {
@@ -43,10 +47,12 @@
     
     CGSize size = [self imgViewOriginSize];
     
-    CGRect frame = CGRectMake(0, 70, size.width, size.height);
+    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;
-    // CGRectMake(0, 70, CGRectGetWidth(self.previewScroll.frame), CGRectGetHeight(self.previewScroll.frame) - 150)
 }
 
 - (BOOL)prefersStatusBarHidden {
@@ -84,8 +90,12 @@
     UIImage *img = nil;
     
 //    UIGraphicsBeginImageContext(view.frame.size);
-    UIGraphicsBeginImageContextWithOptions(view.frame.size, NO, [UIScreen mainScreen].scale);
-    [view.layer renderInContext:UIGraphicsGetCurrentContext()];
+    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();
     
@@ -100,7 +110,7 @@
     rect.size.height *= scale;
     rect.size.width *= scale;
     CGImageRef imgRef = CGImageCreateWithImageInRect(image.CGImage, rect);
-    UIImage *img = [UIImage imageWithCGImage:imgRef scale:0 orientation:3];
+    UIImage *img = [UIImage imageWithCGImage:imgRef scale:0 orientation:image.imageOrientation];
     CGImageRelease(imgRef);
     return img;
     
@@ -117,28 +127,12 @@
 
 - (IBAction)usePhotoClick:(UIButton *)sender {
     
-    [self testimg];
-   // [self.navigationController popViewControllerAnimated:YES];
-    return;
-    
     if (self.photoHandler) {
         
         CGRect imgRect = self.imgView.frame;
         CGRect editRect = self.editContainer.frame;
-//        CGRect screenRect = self.view.bounds;
-//        CGFloat screen_img_x = (CGRectGetWidth(imgRect) - CGRectGetWidth(screenRect)) * 0.5;
-//        CGFloat screen_img_y = (CGRectGetHeight(imgRect) - CGRectGetHeight(screenRect)) * 0.5;
-//        CGRect rect = CGRectMake(screen_img_x + editRect.origin.x, screen_img_y + editRect.origin.y, editRect.size.width, editRect.size.height);
-//        
-//        CGFloat scale = self.preImage.size.width / CGRectGetWidth(imgRect);
-//        
-//        CGRect clipImgRect = CGRectMake(rect.origin.x * scale, rect.origin.y * scale, rect.size.width * scale, rect.size.height * scale);
-  
         CGPoint contentOffset = self.previewScroll.contentOffset;
-        CGRect clipRect = CGRectMake(editRect.origin.x + contentOffset.x, editRect.origin.y + contentOffset.y - imgRect.origin.y, editRect.size.width, editRect.size.height);
-        
-        CGFloat w = CGImageGetWidth(self.preImage.CGImage);
-        CGFloat h = CGImageGetHeight(self.preImage.CGImage);
+        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;
@@ -146,64 +140,65 @@
         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);
-//        CGRect clipImgRect = CGRectMake(w * xp, h * yp, h * hp, w * wp);
+        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);
     }
     [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;
-}
+//-(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 {
@@ -218,46 +213,46 @@
     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;
+//#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;
 //    }
-    
-    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;
-}
+//    
+//    
+////    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;
+//}
 
 
 

+ 17 - 7
RA Image/RA Image/UploadViewController.m

@@ -39,8 +39,8 @@
 //    appdelegate.uploadManager.delegate = self;
 }
 - (void)clearList {
-            AppDelegate* appdelegate = (AppDelegate* )[UIApplication sharedApplication].delegate;
     
+    AppDelegate* appdelegate = (AppDelegate* )[UIApplication sharedApplication].delegate;
     if(appdelegate.uploadManager.arr_queue.count==0)
     {
         [RAUtils alert_view:nil title:@"Upload list is empty."];
@@ -58,6 +58,7 @@
                [arr_tasks addObject:task];
         }
         [appdelegate.uploadManager removeTasks:arr_tasks];
+        
     }];
     
     [alert addAction:OK];
@@ -299,12 +300,21 @@
 //    }
 //}
 //
-//- (void)tableView:(UITableView *)tableView didEndDisplayingCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
-//    UploadCell *upCell = (UploadCell *)cell;
-//    upCell.name = nil;
-//    upCell.progress = 0;
-//    upCell.state = nil;
-//}
+- (void)tableView:(UITableView *)tableView didEndDisplayingCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
+    UploadCell *upCell = (UploadCell *)cell;
+    upCell.name = nil;
+    upCell.progress = 0;
+    upCell.state = nil;
+    upCell.errorMsg = nil;
+    
+    AppDelegate* Appdelegate=(AppDelegate*)[UIApplication sharedApplication].delegate;
+    if (indexPath.row < Appdelegate.uploadManager.arr_queue.count) {// Clear List先调用此方法,再调用numberOfRowsInSection,所以先判断避免Crash
+        NSDictionary * item_json = Appdelegate.uploadManager.arr_queue[indexPath.row];
+        RAUploadOperation* op = item_json[@"operation"];
+        op.updateUI = nil;
+    }
+    
+}
 /*
 #pragma mark - UploadManager Delegate