欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

iOS實(shí)現(xiàn)壓縮圖片上傳功能

 更新時(shí)間:2016年04月28日 16:42:54   作者:風(fēng)吹屁股微微涼  
這篇文章主要介紹了iOS實(shí)現(xiàn)壓縮圖片上傳功能,iOS中常常需要打開(kāi)相機(jī),選擇圖片上傳或者拍照上傳,如何實(shí)現(xiàn)壓縮圖片并上傳圖片,想要了解的朋友可以參考一下

本文實(shí)例為大家分享了iOS實(shí)現(xiàn)壓縮圖片上傳功能,供大家參考,具體內(nèi)容如下

#pragma mark - 打開(kāi)相機(jī)
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary<NSString *,id> *)info{
  UIImage *image = info[UIImagePickerControllerOriginalImage];
  self.currentTapCell.photoManageImgView.image = image;
  NSIndexPath * indexPath = [self.baseTable indexPathForCell:self.currentTapCell];
  NSString * key = [NSString stringWithFormat:@"ineed%u%u", indexPath.row, indexPath.section];
    [[NetEngineHelper shareNetEngine] postUploadWithUrl:k_uploadPhoto_url image:image fileName:[NSString stringWithFormat:@"%@.png", key] fileType:@"PNG/JPEG/JPG" success:^(id response) {
    if ([response[@"STATUS"] intValue] != 0) {
      NSString * str = @"";
      if (response[@"ERRORDESC"]) {
        str = response[@"ERRORDESC"];
      }else{
        str = @"系統(tǒng)異常";
      }
      [AlertHelper shareAlertHelper].onVC = self;
      [AlertHelper shareAlertHelper].alertTitle = str;
      [AlertHelper shareAlertHelper].alertMessage = nil;
      [[AlertHelper shareAlertHelper] alertVcWithSureAction:^(id response) {
         
      }];
    }else{
      [AlertHelper shareAlertHelper].onVC = self;
      [AlertHelper shareAlertHelper].alertTitle = @"上傳成功";
      [AlertHelper shareAlertHelper].alertMessage = nil;
      [[AlertHelper shareAlertHelper] alertVcWithSureAction:^(id response) {
         
      }];
       
      if ([self.currentTapCell.photoDescribeLable.text isEqualToString:@"上傳診斷證明"]) {
        [self.successUploadDic setValue:response[@"FILEID"] forKey:@"PROVEID"];
      }
      if ([self.currentTapCell.photoDescribeLable.text isEqualToString:@"上傳病歷首頁(yè)"]){
        [self.successUploadDic setValue:response[@"FILEID"] forKey:@"CASEHOMEID"];
      }
       
       
       
      NSLog(@"上傳結(jié)果  %@", response);
    }
 
  } fail:^(NSError *error) {
    [AlertHelper shareAlertHelper].onVC = self;
    [AlertHelper shareAlertHelper].alertTitle = error.userInfo[@"NSLocalizedDescription"];
    [AlertHelper shareAlertHelper].alertMessage = nil;
    [[AlertHelper shareAlertHelper] alertVcWithSureAction:^(id response) {
       
    }];
 
  }];
   
   
  [self dismissViewControllerAnimated:YES completion:^{
     
  }];
}
          
 
 
#pragma mark - 打開(kāi)相機(jī)
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary<NSString *,id> *)info{
  UIImage *image = info[UIImagePickerControllerOriginalImage];
  self.currentTapCell.photoManageImgView.image = image;
  NSIndexPath * indexPath = [self.baseTable indexPathForCell:self.currentTapCell];
  NSString * key = [NSString stringWithFormat:@"ineed%u%u", indexPath.row, indexPath.section];
    [[NetEngineHelper shareNetEngine] postUploadWithUrl:k_uploadPhoto_url image:image fileName:[NSString stringWithFormat:@"%@.png", key] fileType:@"PNG/JPEG/JPG" success:^(id response) {
    if ([response[@"STATUS"] intValue] != 0) {
      NSString * str = @"";
      if (response[@"ERRORDESC"]) {
        str = response[@"ERRORDESC"];
      }else{
        str = @"系統(tǒng)異常";
      }
      [AlertHelper shareAlertHelper].onVC = self;
      [AlertHelper shareAlertHelper].alertTitle = str;
      [AlertHelper shareAlertHelper].alertMessage = nil;
      [[AlertHelper shareAlertHelper] alertVcWithSureAction:^(id response) {
         
      }];
    }else{
      [AlertHelper shareAlertHelper].onVC = self;
      [AlertHelper shareAlertHelper].alertTitle = @"上傳成功";
      [AlertHelper shareAlertHelper].alertMessage = nil;
      [[AlertHelper shareAlertHelper] alertVcWithSureAction:^(id response) {
         
      }];
       
      if ([self.currentTapCell.photoDescribeLable.text isEqualToString:@"上傳診斷證明"]) {
        [self.successUploadDic setValue:response[@"FILEID"] forKey:@"PROVEID"];
      }
      if ([self.currentTapCell.photoDescribeLable.text isEqualToString:@"上傳病歷首頁(yè)"]){
        [self.successUploadDic setValue:response[@"FILEID"] forKey:@"CASEHOMEID"];
      }
       
       
       
      NSLog(@"上傳結(jié)果  %@", response);
    }
 
  } fail:^(NSError *error) {
    [AlertHelper shareAlertHelper].onVC = self;
    [AlertHelper shareAlertHelper].alertTitle = error.userInfo[@"NSLocalizedDescription"];
    [AlertHelper shareAlertHelper].alertMessage = nil;
    [[AlertHelper shareAlertHelper] alertVcWithSureAction:^(id response) {
       
    }];
 
  }];
   
   
  [self dismissViewControllerAnimated:YES completion:^{
     
  }];
}
          
 
 
 
/**上傳文件*/
-(void)postUploadWithUrl:(NSString *)urlStr image:(UIImage *)image fileName:(NSString *)fileName fileType:(NSString *)fileTye success:(Success)success fail:(Faile)fail{
   
  NSString * resultStr = [urlStr stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
  self.success = success;
  self.failer = fail;
  AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
  manager.responseSerializer = [AFHTTPResponseSerializer serializer];
  manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"text/html",@"application/json",@"text/plain" ,nil];
  [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
  manager.responseSerializer=[AFJSONResponseSerializer serializer];
  manager.requestSerializer = [AFHTTPRequestSerializer serializer];
  [manager.securityPolicy setAllowInvalidCertificates:YES];
   
  UIApplication *application = [UIApplication sharedApplication];
  application.networkActivityIndicatorVisible = YES;
  [manager POST:resultStr parameters:nil constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
     
    NSData * imgData = UIImageJPEGRepresentation(image, 0.02);
    [formData appendPartWithFileData:imgData name:@"FILENAME" fileName:fileName mimeType:fileTye];
     
     
  } success:^(AFHTTPRequestOperation *operation, id responseObject) {
    success(responseObject);
    application.networkActivityIndicatorVisible = NO;
  } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
    fail(error);
    application.networkActivityIndicatorVisible = NO;
  }];
}

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家學(xué)習(xí)iOS程序設(shè)計(jì)有所幫助。

相關(guān)文章

  • 基于iOS pod最新的安裝和使用方法(分享)

    基于iOS pod最新的安裝和使用方法(分享)

    下面小編就為大家分享一篇基于iOS pod最新的安裝和使用方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
    2018-01-01
  • iOS實(shí)現(xiàn)鎖屏頁(yè)面控制音樂(lè)播放

    iOS實(shí)現(xiàn)鎖屏頁(yè)面控制音樂(lè)播放

    這篇文章主要為大家詳細(xì)介紹了iOS實(shí)現(xiàn)鎖屏頁(yè)面控制音樂(lè)播放,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2019-12-12
  • scrollview tableView嵌套解決方案示例

    scrollview tableView嵌套解決方案示例

    這篇文章主要介紹了scrollview tableView嵌套解決方案示例的代碼,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-08-08
  • IOS 開(kāi)發(fā)之UISearchBar 詳解及實(shí)例

    IOS 開(kāi)發(fā)之UISearchBar 詳解及實(shí)例

    這篇文章主要介紹了IOS 開(kāi)發(fā)之UISearchBar 詳解及實(shí)例的相關(guān)資料,主要介紹 IOS UISearchBar的使用,附有實(shí)例代碼,需要的朋友可以參考下
    2016-12-12
  • iOS倒計(jì)時(shí)的實(shí)現(xiàn)方法

    iOS倒計(jì)時(shí)的實(shí)現(xiàn)方法

    這篇文章主要為大家詳細(xì)介紹了iOS倒計(jì)時(shí)的實(shí)現(xiàn)方法,點(diǎn)擊進(jìn)行倒計(jì)時(shí)準(zhǔn)備,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-03-03
  • iOS中 LGLAlertView 提示框的實(shí)例代碼

    iOS中 LGLAlertView 提示框的實(shí)例代碼

    這篇文章主要介紹了iOS中 LGLAlertView 提示框的實(shí)例代碼非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下
    2016-09-09
  • iOS實(shí)現(xiàn)消息推送及原理分析

    iOS實(shí)現(xiàn)消息推送及原理分析

    這篇文章主要為大家詳細(xì)介紹了iOS實(shí)現(xiàn)消息推送,及針對(duì)消息推送原理進(jìn)行分析,感興趣的小伙伴們可以參考一下
    2016-08-08
  • iOS文字漸變色效果的實(shí)現(xiàn)方法

    iOS文字漸變色效果的實(shí)現(xiàn)方法

    在大家日常開(kāi)發(fā)iOS的過(guò)程中,可能會(huì)遇到要實(shí)現(xiàn)文字漸變色的效果,這篇文章文章通過(guò)示例代碼和詳細(xì)的步驟介紹了如何利用iOS實(shí)現(xiàn)文字漸變色的效果,實(shí)現(xiàn)后的很不錯(cuò),感興趣的朋友們下面來(lái)一起看看吧。
    2016-10-10
  • iOS中獲取系統(tǒng)相冊(cè)中的圖片實(shí)例

    iOS中獲取系統(tǒng)相冊(cè)中的圖片實(shí)例

    這篇文章主要介紹了iOS中獲取系統(tǒng)相冊(cè)中的圖片實(shí)例,具有一定的參考價(jià)值沒(méi)有需要的朋友可以了解一下。
    2016-11-11
  • 詳解Objective-C設(shè)計(jì)模式編程中對(duì)備忘錄模式的運(yùn)用

    詳解Objective-C設(shè)計(jì)模式編程中對(duì)備忘錄模式的運(yùn)用

    這篇文章主要介紹了Objective-C設(shè)計(jì)模式編程中對(duì)備忘錄模式的運(yùn)用,文中結(jié)合了Cocoa框架下應(yīng)用的實(shí)例來(lái)加以講解,需要的朋友可以參考下
    2016-03-03

最新評(píng)論