从UIViewController返回后,UIImagePickerController获得白屏

时间:2011-07-14 04:02:19

标签: iphone uiimagepickercontroller

情况如下:

拍照后
[UIImagePickerController takePicture];

以下委托功能:

-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info

将被调用。

里面的代码是

NSLog(@"Photo taken");
UIImage *newImage = [self resizeImage:[info objectForKey:UIImagePickerControllerOriginalImage]];
NSLog(@"Width: %d, Height: %d ",(int)newImage.size.width, (int)newImage.size.height);
//[imagePickerController dismissModalViewControllerAnimated:YES];
ProcessCompleteView *pcv = [[ProcessCompleteView alloc] initWithNibName:@"ProcessCompleteView" bundle:nil];
[imagePickerController presentModalViewController:pcv animated:YES];
[pcv release];

我已经调用了另一个视图来显示......当我使用 dismissModalViewController 从pcv返回时,应该显示相机实时捕获的区域变为白色。但是,当我关闭 UIImagePickerController 并再次呈现它时,相机工作正常!

任何人都可以帮我解决这个奇怪的问题吗?

感谢。

1 个答案:

答案 0 :(得分:0)

显示视图的顺序不正确。

正确的顺序是: 父控制器的视图显示 - > UIImagePickerController的视图显示 - > UIImagePickerController的隐藏视图 - > ProcessCompleteView show

所以,请删除

ProcessCompleteView *pcv = [[ProcessCompleteView alloc] initWithNibName:@"ProcessCompleteView" bundle:nil];
[imagePickerController presentModalViewController:pcv animated:YES];
[pcv release];

进入父控制器的viewWillAppear方法,然后调用

ProcessCompleteView *pcv = [[ProcessCompleteView alloc] initWithNibName:@"ProcessCompleteView" bundle:nil];
[parentController presentModalViewController:pcv animated:YES];
[pcv release];