Sometimes UIImageView seems to reject the image taken with iPhone Camera

Posted by maxbareis on Stack Overflow See other posts from Stack Overflow or by maxbareis
Published on 2010-03-03T21:17:43Z Indexed on 2010/04/10 5:53 UTC
Read the original article Hit count: 367

Filed under:
|
|
|

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

© Stack Overflow or respective owner

Related posts about iphone

Related posts about camera