I want to get the image frm imagepickercontroller
.But my code doesn't have any effect
Here is the code..
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
[picker dismissModalViewControllerAnimated:YES];
imageview.image = [UIImage imageNamed:[info objectForKey:@"UIImagePickerControllerOriginalImage"]];
You can try setting UIImagePickerController. mediaTypes explicitly for the types you want. By default it is set to [kUTTypeImage] which covers all image types - jpeg, png, gif, heif and more...
storyboard file and add two elements inside the view controller. The first one is a button, which will show up an image picker modal whenever it gets pressed. The second one is an image view. I'm going to put a placeholder image at first, but once the user selected an image, we'll display that image to that view.
You can try this code to access an Image returned from the picker
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
[picker dismissModalViewControllerAnimated:YES];
UIImage* originalImage = nil;
originalImage = [info objectForKey:UIImagePickerControllerEditedImage];
if(originalImage==nil)
{
originalImage = [info objectForKey:UIImagePickerControllerOriginalImage];
}
if(originalImage==nil)
{
originalImage = [info objectForKey:UIImagePickerControllerCropRect];
}
//At this point you have the selected image in originalImage
[self saveImageToDocumentDirectory:originalImage];
}
Try
imageview.image = (UIImage*) [info objectForKey:UIImagePickerControllerOriginalImage];
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