简体   繁体   English

从网络将图像保存在模拟器照片库中

[英]saving image from web in simulator photo gallery

i am downloading an image from the internet but saving it on the desktop.I want to save it in photo gallery of the iphone. 我正在从互联网下载图像,但将其保存在桌面上。我想将其保存在iPhone的照片库中。 How is this possible? 这怎么可能?

my code is here: 我的代码在这里:

NSString *docDir = @"/Users/gaurav/Desktop";
NSString *pngFilePath = [NSString stringWithFormat:@"%@/neetu%d.png",docDir , r];
r++;

//NSString *pngFilePath = [NSString stringWithFormat:@"%@/flower.png",docDir];
NSData *data1 = [NSData dataWithData:UIImagePNGRepresentation(image)];
[data1 writeToFile:pngFilePath atomically:YES];

You can use this function: 您可以使用此功能:

UIImageWriteToSavedPhotosAlbum(UIImage *image, id completionTarget, SEL completionSelector, void *contextInfo);

You only need completionTarget, completionSelector and contextInfo if you want to be notified when the image is done saving, otherwise you can pass in nil. 如果要在图像保存完成时收到通知,则只需要completementTarget,completionSelector和contextInfo,否则可以传入nil。

Look into UIImageWriteToSavedPhotosAlbum 查看UIImageWriteToSavedPhotosAlbum

UIImageWriteToSavedPhotosAlbum working... sometimes UIImageWriteToSavedPhotosAlbum工作...有时

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM