如何检查图像是否存在于照片库中(如果存在则显示,如果未在目标c中下载)

时间:2017-07-05 09:06:35

标签: ios objective-c uiimageview photolibrary

我是iOS的新手,我在照片库上是否存在检查图像时遇到问题。

我的代码是这样的。将图像保存到照片库:

 NSString *strImgURLAsString = @"Imagename.png";
    [strImgURLAsString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    strImgURLAsString = [strImgURLAsString stringByReplacingOccurrencesOfString:@" " withString:@"%20"];
    NSURL *imgURL = [NSURL URLWithString:strImgURLAsString];
    [NSURLConnection sendAsynchronousRequest:[NSURLRequest requestWithURL:imgURL] queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {
        if (!connectionError) {
            img = [[UIImage alloc] initWithData:data];
            if (img==nil) {

            }
            procedureimage.image=img;

            UIImageWriteToSavedPhotosAlbum(img, nil, nil, nil);//Saving image to photo library.


            [customActivityIndicator stopAnimating];

            // pass the img to your imageview
        }else{
            NSLog(@"%@",connectionError);
        }
    }];

如何检查照片库中是否存在图像?

0 个答案:

没有答案