UIImagePickerController,飞机模式激活时出现奇怪的崩溃

时间:2011-08-29 15:47:37

标签: iphone objective-c cocoa-touch uiimagepickercontroller

我在其中一个应用中遇到了一个非常奇怪的崩溃,希望你能指出我正确的方向:

我使用UIImagePickerController让用户选择或拍摄照片,然后将照片上传到网络服务器。除非用户激活飞行模式,否则一切正常。如果飞行模式处于活动状态,则当我调用[self dismissModalViewControllerAnimated:YES];关闭ImagePicker并且编译器抛出 - [UIImage isKindOfClass:]: message sent to deallocated instance时,应用程序将崩溃。一些代码:

//here I invoke the ImagePicker:
UIImagePickerController *picker= [[UIImagePickerController alloc]init];
picker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentModalViewController:picker animated:YES];
[picker release];

//crash happens here:
-(void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
[self dismissModalViewControllerAnimated:YES];
}

//or here:
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage :    (UIImage *)image editingInfo:(NSDictionary *)editingInfo
{
//processing the image...

[self dismissModalViewControllerAnimated:YES];
}

同样,如果飞机模式未激活,则一切正常。有什么想法吗?

0 个答案:

没有答案