我是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);
}
}];
如何检查照片库中是否存在图像?