我有一个应用程序,我在其中显示照片选择器(UIImagePickerController),但在用户关闭后,只有单次触摸才起作用。我想我知道问题的根源,但我不知道如何解决它......在显示模式对话框之前,触摸期间的堆栈如下所示:
...
#3 0x00074de0 in -[EAGLView touchesBegan:withEvent:] at EAGLView.m:289
#4 0x30910f33 in -[UIWindow _sendTouchesForEvent:]
...
但是在显示然后删除模式对话框之后,堆栈有这两个神秘的forwardMethod2调用:
...
#3 0x00074de0 in -[EAGLView touchesBegan:withEvent:] at EAGLView.m:289
#4 0x3098dc95 in forwardMethod2
#5 0x3098dc95 in forwardMethod2
#6 0x30910f33 in -[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????
}
在清理选择器视图时一定缺少一些东西......非常感谢帮助:)