zoukankan      html  css  js  c++  java
  • 下载图片,

    -(void)downImage

    {

        AlbumInfo *info = [self.dataArray objectAtIndex:index];

        NSString *filePath = [[SandBoxPath pathForCaches]stringByAppendingPathComponent:@"/a.png"];

        [self showLoadingView];

        NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:info.url]];

        AFDownloadRequestOperation *downloadOperation = [[AFDownloadRequestOperation alloc]initWithRequest:request targetPath:filePath shouldResume:NO];

        [downloadOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {

            [self hideLoadingView];

            UIImage *image = [UIImage imageWithContentsOfFile:filePath];

            if (image) {

                UIImageWriteToSavedPhotosAlbum(image, self, nil, NULL);

                [self showToast:@"保存成功!"];

            }else{

                [self showToast:@"保存失败!"];

            }

            

        } failure:^(AFHTTPRequestOperation *operation, NSError *error) {

            [self hideLoadingView];

            [self showToast:@"保存失败!"];

     

        }];

        

        [downloadOperation setProgressiveDownloadProgressBlock:^(AFDownloadRequestOperation *operation, NSInteger bytesRead, long long totalBytesRead, long long totalBytesExpected, long long totalBytesReadForFile, long long totalBytesExpectedToReadForFile) {

            TTLog(@"bytesread: %d",bytesRead);

        }];

        NSOperationQueue *downloadQueue = [[NSOperationQueue alloc]init];

        [downloadQueue addOperation:downloadOperation];

    }

  • 相关阅读:
    jq 字符串去除空格
    wpf 加载资源文件
    wpf 寻找TreeView的子元素,并对其进行操作
    IIS发布MVC ASP.NET网站
    wpf Binding 小记录
    asp.net mvc表单异步提交
    把路径设置为全局变量
    MVC将服务器端的物理路径转换为服务器路径
    silverlight控件阴影效果示例
    NLP的12条前提假设
  • 原文地址:https://www.cnblogs.com/guligei/p/3804374.html
Copyright © 2011-2022 走看看