facebook twitter hatena line email

Ios/swift/画像保存

提供: 初心者エンジニアの簡易メモ
2016年8月1日 (月) 09:44時点におけるAdmin (トーク | 投稿記録)による版 (ページの作成:「==画像保存== UIImageWriteToSavedPhotosAlbum(_imageView.image!, self, #selector(ImageDetailViewController.image(_:didFinishSavingWithError:contextInfo:)), nil)...」)

(差分) ←前の版 | 最新版 (差分) | 次の版→ (差分)
移動: 案内検索

画像保存

   UIImageWriteToSavedPhotosAlbum(_imageView.image!, self, #selector(ImageDetailViewController.image(_:didFinishSavingWithError:contextInfo:)), nil)
   
   func image(image: UIImage, didFinishSavingWithError error: NSError!, contextInfo: UnsafeMutablePointer<Void>) {
       var title:String = "保存完了"
       var message:String = "アルバムへの保存完了"
       if error != nil {
           title = "エラー"
           message = "アルバムへの保存に失敗しました"
       }
       let alert:UIAlertController = UIAlertController(title: title, message: message, preferredStyle: UIAlertControllerStyle.Alert)
       alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler: {
           (action) -> Void in
           print("ok")
       }))
       self.presentViewController(alert, animated: true, completion: {})
   }

参考:http://swift-studying.com/blog/swift/?p=473