Skip to content

Commit

Permalink
alert added to show confirmation to users when their Id Card successf…
Browse files Browse the repository at this point in the history
…ully saved in photos
  • Loading branch information
iamank1t committed Apr 17, 2018
1 parent c5479fc commit 1122074
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion mySteemitIdCard/IDcardVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class IDcardVC: UIViewController {
let image = imageWithView(view: self.mainView)

//Then save your ID Card image
UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil)
UIImageWriteToSavedPhotosAlbum(image, self, #selector(image(_:didFinishSavingWithError:contextInfo:)), nil)
}

//function to convert the ID Card UIView into an UIImage
Expand All @@ -76,4 +76,19 @@ class IDcardVC: UIViewController {
return image!
}

// function to show users alert, if image saved or not
@objc func image(_ image: UIImage, didFinishSavingWithError error: Error?, contextInfo: UnsafeRawPointer) {
if let error = error {
// we got back an error!
let ac = UIAlertController(title: "Save error", message: error.localizedDescription, preferredStyle: .alert)
ac.addAction(UIAlertAction(title: "OK", style: .default))
present(ac, animated: true)
} else {
let ac = UIAlertController(title: "Yureka!", message: "Your Steem Id Card has been saved to your photos.", preferredStyle: .alert)
ac.addAction(UIAlertAction(title: "Great", style: .default))
present(ac, animated: true)
}
}


}

0 comments on commit 1122074

Please sign in to comment.