Created
November 25, 2018 16:36
-
-
Save vialyx/dff0768018ad600df19d79e651b265cd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
final class ViewController: UIViewController { | |
@IBAction func photoLibraryDidTap(_ sender: Any) { | |
let imagePickerController = UIImagePickerController() | |
imagePickerController.delegate = self | |
present(imagePickerController, animated: true, completion: nil) | |
} | |
} | |
// MARK: - UIImagePickerControllerDelegate | |
extension ViewController: UIImagePickerControllerDelegate { | |
func imagePickerControllerDidCancel(_ picker: UIImagePickerController) { | |
print("imagePickerControllerDidCancel") | |
dismiss(animated: true, completion: nil) | |
} | |
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) { | |
print("imagePickerController didFinishPickingMediaWithInfo: \(info)") | |
if let image: UIImage = info[UIImagePickerController.InfoKey.originalImage] as? UIImage { | |
// Here you can manage image | |
print("image size: \(image.size)") | |
} | |
dismiss(animated: true, completion: nil) | |
} | |
} | |
// MARK: - UINavigationControllerDelegate | |
extension ViewController: UINavigationControllerDelegate {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment