我有一个应用程序,我在其中显示照片选择器(UIImagePickerController),但在用户关闭它后,只有单次触摸起作用。而且我想我知道问题的根源,但我不知道如何解决它......在我显示模态对话框之前,触摸期间的堆栈如下:
... #3 0x00074de0 in -[EAGLView touchesBegan:withEvent:] at EAGLView.m:289 #4 0x30910f33 在 -[UIWindow _sendTouchesForEvent:] ...
但是在显示然后删除模式对话框之后,堆栈有这两个神秘的 forwardMethod2 调用:
... #3 0x00074de0 in -[EAGLView touchesBegan:withEvent:] at EAGLView.m:289 #4 0x3098dc95 在 forwardMethod2 #5 0x3098dc95 在 forwardMethod2 #6 0x30910f33 在 -[UIWindow _sendTouchesForEvent:] ...
下面是我用来显示和删除 UIImagePickerController 的代码: 注意:1.pickerViewController 是这个类的成员,它扩展了 UIViewController) 2.Director 来自 Cocos2D,并且只包含一个直接附加在名为 openGLView 的根窗口中的单个视图,它这就是为什么我制作了一个 UIViewController 来容纳我的图像选择器。
-(void)choosePhoto: (id)sender{
UIImagePickerController *imagePickerController = pickerViewController.imagePickerController;
imagePickerController.delegate = self;
imagePickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
imagePickerController.allowsImageEditing = YES;
UIView *theView = [[Director sharedDirector] openGLView];
UIView *pickerViewControllerView = pickerViewController.view;
[theView addSubview:pickerViewControllerView];
[pickerViewController presentModalViewController:imagePickerController animated:YES];
}
以及关闭对话框的代码:
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)imagePickerController
{
// Dismiss the image selection
[pickerViewController dismissModalViewControllerAnimated:YES];
[pickerViewController.view removeFromSuperview];
// HERE... IS THERE MORE WORK TO BE DONE TO COMPLETELY REMOVE THE PICKER VIEW????
}
在清理选择器视图时我必须缺少一些东西......非常感谢帮助:)