I am just going to new in swift,
I have one button on click of which opening front camera of iPad and clicking the photo of user, and when clicked on use photo,
func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : AnyObject])
is getting called of imagePickerController
this is the line of code..
func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : AnyObject])
{
picker .dismissViewControllerAnimated(true, completion: nil)
photoImgView.image=info[UIImagePickerControllerOriginalImage] as? UIImage
if imageData == nil {
imageData = UIImageJPEGRepresentation((info[UIImagePickerControllerOriginalImage] as? UIImage)!, 1)
}
}
but when I submit it shows found nil value
,
after debugging got this point in func didFinishPickingMediaWithInfo
which says,
(lldb) po imageData
expression produced error: Execution was interrupted, reason: step over.
The process has been returned to the state before expression evaluation.
I am not getting what I am doing wrong. as I am not good in swift, can any one please guide me for the same. I am stuck at this point.
Thanks in advance.
I got the solution, Thanks to my colleague,
I am capturing the image from imagePickerController and getting saved in NSData
.
But the image captured it around 6-7 MB (iPad camera captures the image with this size by default)
and when saving it into NSData
and then converting it into base64 format goes out of size and then compiler throws the issue.
Issue solved just by changing in line code for UIImageJPEGRepresentation
func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : AnyObject])
{
photoImgView.image=info[UIImagePickerControllerOriginalImage] as? UIImage
imageData = UIImageJPEGRepresentation((info[UIImagePickerControllerOriginalImage] as? UIImage)!, 0.5)
print(imageData)
picker .dismissViewControllerAnimated(true, completion: nil)
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With