I select a photo from PhotoLibrary and How can I achieve below tasks
In this case, I am using Swift. I need to reconstruct the image in the next VC either thru :
a) Bytes
b) Image
by means of using Segue or user class. If the Image file is huge , it is better pass by segue or class.
1) Get the Image or Bytes from the UIImagePickerController
2) How to pass the Image Bytes to next next VC
use Segue
or use class
Do I use user class to store the Image or Bytes?
3) How to get the Height and Width so that I can know if the image is in portrait or landscape mode.
4) How to check if there is image in ImageView?
I have a btn to click to check before navigating to next VC
Your help is greatly appreciated
Below is code I used:
@IBOutlet var imageView: UIImageView!
let imagePicker = UIImagePickerController()
@IBAction func loadImageButtonTapped(sender: UIButton) {
imagePicker.allowsEditing = false
imagePicker.sourceType = .PhotoLibrary
presentViewController(imagePicker, animated: true, completion: nil)
}
//-- - UIImagePickerControllerDelegate Methods
func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [NSObject : AnyObject]) {
if let pickedImage = info[UIImagePickerControllerOriginalImage] as? UIImage {
imageView.contentMode = .ScaleAspectFit
imageView.image = pickedImage
}
dismissViewControllerAnimated(true, completion: nil)
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…