Last active
November 9, 2019 21:40
-
-
Save mohdsanadzakirizvi/157fc13f48fe8ff134b7ec9a2e24bb41 to your computer and use it in GitHub Desktop.
This file contains 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 CoreML | |
import Vision | |
import UIKit | |
class ViewController: UIViewController { | |
// MARK: - IBOutlets | |
@IBOutlet weak var scene: UIImageView! | |
@IBOutlet weak var answerLabel: UILabel! | |
// MARK: - View Life Cycle | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
guard let image = UIImage(named: "scenery") else { | |
fatalError("no starting image") | |
} | |
scene.image = image | |
} | |
} | |
// MARK: - IBActions | |
extension ViewController { | |
@IBAction func pickImage(_ sender: Any) { | |
let pickerController = UIImagePickerController() | |
pickerController.delegate = self | |
pickerController.sourceType = .savedPhotosAlbum | |
present(pickerController, animated: true) | |
} | |
} | |
// MARK: - UIImagePickerControllerDelegate | |
extension ViewController: UIImagePickerControllerDelegate { | |
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) { | |
dismiss(animated: true) | |
guard let image = info[UIImagePickerControllerOriginalImage] as? UIImage else { | |
fatalError("couldn't load image from Photos") | |
} | |
scene.image = image | |
} | |
} | |
// MARK: - UINavigationControllerDelegate | |
extension ViewController: UINavigationControllerDelegate { | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment