Просмотр исходного кода

1.修改上传按钮响应,重制视图页面。

Pen Li 9 лет назад
Родитель
Сommit
9162b83352

+ 3 - 1
RA Image/RA Image/BasicModeViewController.m

@@ -136,10 +136,12 @@
             if ([name hasSuffix:@".png"]) {
                 NSString *path = [dir stringByAppendingPathComponent:name];
                 UIImage *img = [UIImage imageWithContentsOfFile:path];
+                NSString *md5 = [RAUtils md5WithFile:path];
                 NSDictionary *photoDic = @{
                                            @"photo" : img,
                                            @"check" : @(NO),
-                                           @"path"  : path
+                                           @"path"  : path,
+                                           @"md5"   : md5
                                            };
                 [photos addObject:photoDic];
             }

+ 27 - 13
RA Image/RA Image/PopModeViewController.m

@@ -35,6 +35,15 @@
     // Dispose of any resources that can be recreated.
 }
 
+#pragma mark - Private
+
+- (void)clear {
+    self.barcode = nil;
+    [self.imgBtn setBackgroundImage:nil forState:UIControlStateNormal];
+    self.photos = nil;
+    self.photoCount = 0;
+}
+
 #pragma mark - Button Action
 
 - (IBAction)imgBtnClick:(UIButton *)sender {
@@ -71,21 +80,23 @@
     
     for(NSMutableDictionary* photo in self.photos)
     {
-            NSMutableDictionary* task=[[NSMutableDictionary alloc]init];
         
+        NSMutableDictionary* task=[[NSMutableDictionary alloc]init];
         
-            task[@"file_path"]=photo[@"path"];
-            task[@"url"]=Appdelegate.address;
+    
+        task[@"file_path"]=photo[@"path"];
+        task[@"url"]=Appdelegate.address;
+        NSString *md5 = [photo objectForKey:@"md5"];
         
-            NSDictionary* params = @{
-                                     @"user" : Appdelegate.user,
-                                     @"password" : Appdelegate.password,
-                                     @"mode":self.name,
-                                     @"barcode":self.barcode,
-                                     @"_operate":@"upload",
-                                     @"md5":@""
-                                     };
-            task[@"params"]=params;
+        NSDictionary* params = @{
+                                 @"user" : Appdelegate.user,
+                                 @"password" : Appdelegate.password,
+                                 @"mode":self.name,
+                                 @"barcode":self.barcode,
+                                 @"_operate":@"upload",
+                                 @"md5":md5
+                                 };
+        task[@"params"]=params;
         [tasks addObject:task];
 
     }
@@ -95,7 +106,7 @@
     [Appdelegate.uploadManager addTasks:tasks];
     
     
-    
+    [self clear];
     
     UploadViewController *upVC = (UploadViewController *)[self viewControllerInStoryboard:@"Upload" withId:@"UploadViewController"];
     [self.navigationController pushViewController:upVC animated:YES];
@@ -115,6 +126,9 @@
 
 - (void)setBarcode:(NSString *)barcode {
     [super setBarcode:barcode];
+    if (!barcode) {
+        barcode = @"";
+    }
     self.barcodeLabel.text = [NSString stringWithFormat:@"%@:%@",self.barcodeTitle,barcode];
 }
 

+ 9 - 2
RA Image/RA Image/UploadViewController.m

@@ -9,7 +9,7 @@
 #import "UploadViewController.h"
 #import "UploadCell.h"
 
-@interface UploadViewController ()<UITableViewDelegate,UITableViewDataSource>
+@interface UploadViewController ()<UITableViewDelegate,UITableViewDataSource,RAUploadManagerDelegate>
 
 @property (strong, nonatomic) IBOutlet UITableView *uploadTable;
 
@@ -21,6 +21,9 @@
     [super viewDidLoad];
     // Do any additional setup after loading the view.
     [self.view insertSubview:[UIView new] atIndex:0];
+    
+    AppDelegate* appdelegate=(AppDelegate*)[UIApplication sharedApplication].delegate;
+    appdelegate.uploadManager.delegate = self;
 }
 
 - (void)didReceiveMemoryWarning {
@@ -135,7 +138,11 @@
 //    upCell.state = nil;
 //}
 
+#pragma mark - UploadManager Delegate
 
-
+- (void)uploadManager:(RAUploadManager *)manager didRemoveTasks:(NSArray *)tasks {
+    // 修复finish后滑动Table导致数组越界崩溃。
+    [self.uploadTable reloadData];
+}
 
 @end