开发者

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


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];
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜