我在其中一个应用中遇到了一个非常奇怪的崩溃,希望你能指出我正确的方向:
我使用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];
}
同样,如果飞机模式未激活,则一切正常。有什么想法吗?