• 下载图片,


    -(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];

    }

  • 相关阅读:
    客户端入手分析异步更新机制
    前面PRM实例所使用到的MasterPage
    FCKeditor.Net_2.2安全修正版
    PRM–endRequest事件
    PageRequestManager类
    客户端访问PageMethod
    使用ASPJPEG组件生成缩略图
    使用js实现广告切换
    动态添加UpdatePannel
    MSMQ(Microsoft Message Queue,微软消息队列) Asp.Net 简单示例
  • 原文地址:https://www.cnblogs.com/guligei/p/3804374.html
Copyright © 2020-2023  润新知