

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
class ViewController: UIViewController { | |
@IBOutlet var imageview : UIImageView! | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
} | |
@IBAction func didTabButtuon(){ | |
print("test") | |
let vc = UIImagePickerController() | |
vc.sourceType = .photoLibrary | |
vc.delegate = self | |
vc.allowsEditing = true | |
present(vc, animated: true) | |
} | |
} | |
extension ViewController : UIImagePickerControllerDelegate, UINavigationControllerDelegate { | |
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) { | |
if let image = info[UIImagePickerController.InfoKey(rawValue: "UIImagePickerControllerEditedImage")] as? UIImage { | |
imageview.image = image | |
} | |
picker.dismiss(animated: true, completion: nil) | |
} | |
func imagePickerControllerDidCancel(_ picker: UIImagePickerController) { | |
picker.dismiss(animated: true, completion: nil) | |
} | |
} | |
'IOS(Swift)' 카테고리의 다른 글
swift alert image (0) | 2021.04.21 |
---|---|
scrollview zoom in (0) | 2021.04.20 |
performSegue full screen (0) | 2021.04.01 |
navigationController pushViewController (0) | 2021.03.31 |
Swift Alert (0) | 2021.03.17 |