i have a TabBarController in which one tab has an ImageView. Besides, i have a button to display the ImagePicker and the following code:
- (void) imagePickerController:(UIImagePickerController *)picker
didFinishPickingMediaWithInfo:(NSDictionary *)info {
[self dismissModalViewControllerAnimated:YES];
[picker release];
UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
imageView.image = image;
}
But the image doesn't show in the ImageView when this method is called.
Any idea?
Thanks
(I have tried in a separately view and it works so i don't know what is happening)
First of all, you are dismissing your picker first thing, you can try:
UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
imageView.image = image;
[self dismissModalViewControllerAnimated:YES];
or you can try this delegate:
-(void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingImage:(UIImage *)image
editingInfo:(NSDictionary *)editingInfo {
NSData *chosenImage = UIImageJPEGRepresentation(image, 1.0);
yourImage.image = [UIImage imageWithData:chosenImage];
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.