gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 20:30:05 29 4
gpt4 key购买 nike

我有一个应用程序,可以在其中显示照片选择器(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/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com