显示并关闭模态视图控制器 UIImagePickerController 之后,我的 Cocos2d iPhone 应用程序不再看到多次触摸
我有一个应用程序,我在其中显示照片选择器(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????
}
在清理选择器视图时一定缺少一些东西...非常感谢帮助:)
I have an app where I display the photo chooser (UIImagePickerController) but after the user dismisses it only single touches are working. And I think I know the root of the issue, but I don't know how to solve it... Before I show the modal dialog the stack during a touch is as follows:
... #3 0x00074de0 in -[EAGLView touchesBegan:withEvent:] at EAGLView.m:289 #4 0x30910f33 in -[UIWindow _sendTouchesForEvent:] ...
But after showing and then removing the modal dialog the stack has these two mysterious forwardMethod2 calls:
... #3 0x00074de0 in -[EAGLView touchesBegan:withEvent:] at EAGLView.m:289 #4 0x3098dc95 in forwardMethod2 #5 0x3098dc95 in forwardMethod2 #6 0x30910f33 in -[UIWindow _sendTouchesForEvent:] ...
Here is the code I use to display and remove the UIImagePickerController:
Notes:
1. pickerViewController is a member of this class that extends UIViewController)
2. Director is from Cocos2D and contains only a single view attached directly in the root window called openGLView, which is why I made a UIViewController to house my image picker.
-(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];
}
And the code to dismiss the dialog:
- (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????
}
There must be something I'm missing in cleaning up the picker view... Help is greatly appreciated :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
从根窗口向下调查视图层次结构后,我发现在关闭照片选择器后,我的 viewController 的视图被添加为 UITransitionView 下的子视图,因此解决方案是删除 viewController 的视图的超级视图:
After investigating the view hierarchy from the root window down I have found that after dismissing the Photo chooser that my viewController's view was getting added as a child under a UITransitionView so the solution is to remove the superview of my viewController's view instead:
我注意到 CJ Hanson 的解决方案适用于 iPhone:
但不适用于 iPad。 正常方式:
在 iPad 上工作。 我现在只是给两者打电话,似乎工作正常:
也许有更多知识的人可以澄清为什么需要这样做?
I've noticed that CJ Hanson's solution works for me on iPhones:
but not on iPads. The normal way:
works on the iPad. I just call both at the moment and it seems to work ok:
Maybe someone with more knowledge can clarify why this is needed?