Masiar
Masiar

Reputation: 21352

iPhone taking picture leads to white screen after taking picture

I have this code to take a picture in my iPhone application:

-(IBAction) getPhoto:(id) sender {
    UIImagePickerController * picker = [[UIImagePickerController alloc] init];
    picker.delegate = self;

    if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])  {
        picker.sourceType = UIImagePickerControllerSourceTypeCamera;
    }
    else{
        picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
    }

    [self presentModalViewController:picker animated:YES];
}

Then I have this other controller to manage the picture taken:

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo {
    [picker.parentViewController dismissModalViewControllerAnimated:YES];
    imageTaken.image = image;
    NSLog(@"saved!");
}

I tried to launch the app on my iPhone 4 (iOS 4.something) and after taking a picture and clicking on "use" I get a white screen. When testing the app directly on another phone, launched directly from XCode (iOS 5 this time) to check the Log, I tap on "use" but then nothing happens and the Log is correctly printed.

Do you know what's going on? I thought that the screen of the picture was not closing, but I call dismissModalViewController....

Thanks,

Masiar

Upvotes: 1

Views: 1512

Answers (1)

Deepak Danduprolu
Deepak Danduprolu

Reputation: 44633

You should dismiss the modal view controller in this fashion,

[self dismissModalViewControllerAnimated:YES];

And it is better to use imagePickerController:didFinishPickingMediaWithInfo: as the other method is being deprecated.

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
    [self dismissModalViewControllerAnimated:YES];
    imageTaken.image = (UIImage *)[info objectForKey: UIImagePickerControllerEditedImage];
}

Upvotes: 1

Related Questions