Last active
May 24, 2020 12:35
-
-
Save ctkqiang/20e3c9e9a16e67f476ff3a1feeda579c 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 | |
class ViewController: UIViewController, UINavigationControllerDelegate, UIImagePickerControllerDelegate { | |
@IBOutlet weak var ImageDisplay: UIImageView! | |
@IBOutlet weak var CameraButton: UIButton! | |
@IBOutlet weak var LibraryButton: UIButton! | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
// Do any additional setup after loading the view. | |
} | |
override func didReceiveMemoryWarning() { | |
super.didReceiveMemoryWarning() | |
print("Out Of Memory") | |
} | |
@IBAction func CameraButton(_ sender:UIButton) { | |
print("hi") | |
} | |
// Mark: Action: | |
@IBAction func PhotoLibraryAction(sender: UIButton) { | |
let picker = UIImagePickerController() | |
picker.delegate = self | |
picker.sourceType = .photoLibrary | |
// PRevious version ``` presentViewController(picker, animated: true, completion: nil)``` | |
present(picker, animated: true, completion: nil) | |
} | |
@IBAction func CameraAction(sender: UIButton) { | |
let picker = UIImagePickerController() | |
picker.delegate = self | |
picker.sourceType = .camera | |
present(picker, animated: true, completion: nil) | |
} | |
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) { | |
ImageDisplay.image = info[UIImagePickerController.InfoKey.originalImage] as? UIImage; | |
dismiss(animated: true, completion: nil) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment