简体   繁体   English

哪个最好保存照片库中的图像?

[英]which is best to save image in the photo library?

I have came across two ideas of saving images from app to photo library. 我发现了两种将图像从应用程序保存到照片库的想法。

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

  2. ALAssetsLibrary

I used the first one but it takes more time to save. 我使用了第一个,但需要更多时间来保存。 Which is fast way to save images in library? 哪种方法可以快速保存库中的图像?

UIImageWriteToSavedPhotosAlbum should be faster but anyway, you should and you have to do it on a background thread to not block the main thread and the UI. UIImageWriteToSavedPhotosAlbum应该更快,但无论如何,你应该和你必须在后台线程上做到这一点,不要阻止主线程和UI。 Somehow like 不知何故喜欢

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
   UIImageWriteToSavedPhotosAlbum(img.image, nil, nil, nil);
});

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

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