开发者

Insert photos in the photo library at runtime iphone sdk

I have a tableview with custom cells. The cell shows photos which I'm getting in the form of url from an xml which I'm loading in webviews. There might be any number of photos, but I'm showing only first three photos in normal cell view.

When user taps the cell, I want to insert all the photos that are in the form of urls for that indexPath into photo library and display them just like the facebook app.

Can anybo开发者_开发百科dy please tell me:

  1. How to insert photos into photo library at runtime that are in the form of urls?

  2. Shall I erase the previous photos all the time I'm inserting the new ones?

Thanx in advance.


You'll need to download the image with NSURLConnection and in your delegate methods save the downloaded data (in connection:didReceiveData:) in downloadData. Then in connectionDidFinishLoading: create a UIImage out of it with:

image = [[[UIImage alloc] initWithData:downloadData] autorelease];

then to insert the photo into the photo library:

UIImageWriteToSavedPhotosAlbum(image);

I don't think you're allowed to erase images from the Photo Library.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜