iOS Xcode

UIimage 写真アルバムへの保存

UIImageを写真アルバムに保存する簡単な方法。

// 保存するメソッド
- (void) save {
UIImage *image = [self.canvasView UIImage];
SEL sel = @selector(savingImageIsFinished:didFinishSavingWithError:contextInfo:);
UIImageWriteToSavedPhotosAlbum(image, self, sel, NULL);
}

// 保存完了を通知するメソッド
- (void) savingImageIsFinished:(UIImage *)_image
      didFinishSavingWithError:(NSError *)_error
                  contextInfo:(void *)_contextInfo {

  UIAlertView *alert =
    [[UIAlertView alloc] initWithTitle:@"End"
                              message:@"image save completed"
                              delegate:nil
                    cancelButtonTitle:@"OK"
                    otherButtonTitles:nil];

  [alert show];
  [alert release];
} 

-iOS, Xcode
-, , ,

Copyright© LAPTURE , 2020 All Rights Reserved.