iphone - 显示并关闭模态视图 Controller UIImagePickerController 之后,我的 Cocos2d iPhone 应用程序不再看到多次触摸

标签 iphone uiimagepickercontroller multi-touch

我有一个应用程序,可以在其中显示照片选择器(UIImagePickerController),但在用户关闭后,只有单次触摸才起作用。我想我知道问题的根源,但我不知道如何解决它......在显示模式对话框之前,触摸期间的堆栈如下:

...
#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];
}

以及关闭对话框的代码:

- (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????
}

在清理选择器 View 时一定缺少一些东西...非常感谢帮助:)

最佳答案

从根窗口向下调查 View 层次结构后,我发现在关闭照片选择器后,我的 viewController 的 View 被添加为 UITransitionView 下的 subview ,因此解决方案是删除我的 viewController View 的 super View :

- (void)imagePickerControllerDidCancel:(UIImagePickerController *)imagePickerController
{
    // Dismiss the image selection
    [pickerViewController dismissModalViewControllerAnimated:YES];
    [pickerViewController.view.superview removeFromSuperview];
}

关于iphone - 显示并关闭模态视图 Controller UIImagePickerController 之后,我的 Cocos2d iPhone 应用程序不再看到多次触摸,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1247992/

相关文章:

iphone - 打开 native 应用程序。来自 Safari

iphone - 如何检查所选图像是否为全景图像

android - 如何在android中打印手触摸

android - 生成用于测试的多点触控 MotionEvents

iphone - 已退款的应用内购买订阅是否显示为已过期?

iphone - iOS:为什么背景是黑色的?

ios - 此应用程序是否使用广告标识符(IDFA)?

ios - 更改 UIImagePickerController 的裁剪器大小

swift - 我怎样才能使这个 imagePickerController 能够接受编辑过的图像?

javascript - 针对触摸设备进行拖放和滚动