Sometimes UIImageView seems to reject the image taken with iPhone Camera
- by maxbareis
Hi, it is very strange, because this error doesn't happen all the time...
I have the following code:
- (IBAction)getPhoto:(id)sender {
UIImagePickerController * picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
#if TARGET_IPHONE_SIMULATOR
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
#else
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
#endif
[self presentModalViewController:picker animated:YES];
}
with the corresponding delegated selector
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
UIImage *image = [[info objectForKey:@"UIImagePickerControllerOriginalImage"] imageByScalingToSize:CGSizeMake(480, 320)];
[[self imageView] setImage:image];
[picker dismissModalViewControllerAnimated:YES];
}
strange thing is, somtimes the image appears in imageView and sometimes not. I have called
(gdb) po UIImagePNGRepresentation(image)
right after setImage and stuffed the output into a file. The file is a perfect png.
Has anyone experienced the same? Has anyone found a solution for it?
Thanks in advance
Max