保存 UIImage 到相冊
UIKit
UIKit 中一個古老的方法,Objective-C 的形式
void UIImageWriteToSavedPhotosAlbum(UIImage *image, id completionTarget, SEL completionSelector, void *contextInfo);
保存完成后,會調(diào)用 completionTarget 的 completionSelector。如果 completionTarget 不為空,completionTarget 必須實現(xiàn)以下方法
- (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo;
Objective-C 的寫法
- (void)saveImage:(UIImage *)image { UIImageWriteToSavedPhotosAlbum(image, self, @selector(image:didFinishSavingWithError:contextInfo:), nil); } - (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo { if (error) { // Fail } else { // Success } }