解雇图像选择器导致崩溃

时间:2012-03-26 11:21:55

标签: ios iphone uinavigationcontroller uiimagepickercontroller

我使用un UINavigationCtronller从UIViewController导航到一个UIViewController B. 在UIViewController B的视图中,我点击一个按钮并调用UIImagePicker

UIImagePickerController *ipc = [[UIImagePickerController alloc] init];

ipc.sourceType = UIImagePickerControllerSourceTypeCamera;

ipc.delegate = self;

ipc.allowsEditing = NO;

[self presentModalViewController:ipc animated:YES];

如果点击UIImagePicker的“取消”按钮,我会调用

-(void)imagePickerControllerDidCancel:(UIImagePickerController*)picker{



[picker dismissModalViewControllerAnimated:YES];

}

UI将返回UIViewController A而不是B

如果我点击任何地方,应用程序崩溃了。

欢迎任何评论

1 个答案:

答案 0 :(得分:3)

而不是

[picker dismissModalViewControllerAnimated:YES];

[picker.presentingViewController dismissModalViewControllerAnimated:YES];

您希望呈现选择器的ViewController被解雇,而不是选择器本身。