2

写真チューザー(UIImagePickerController)を表示するアプリがありますが、ユーザーがそれを閉じた後は、シングルタッチのみが機能します。そして、私は問題の根本を知っていると思いますが、それを解決する方法がわかりません...モーダルダイアログを表示する前に、タッチ中のスタックは次のとおりです。

..。
#3 0x00074de0 in-[EAGLView touchesBegan:withEvent:] at EAGLView.m:289
#4 0x30910f33 in-[UIWindow _sendTouchesForEvent:]
..。

しかし、モーダルダイアログを表示して削除した後、スタックには次の2つの不思議なforwardMethod2呼び出しがあります。

..。
#3 0x00074de0 in-[EAGLView touchesBegan:withEvent:] at EAGLView.m:289
forwardMethod2の#4 0x3098dc95
forwardMethod2の#5 0x3098dc95
#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????
}

ピッカービューのクリーンアップに欠けているものがあるはずです...ヘルプは大歓迎です:)

4

2 に答える 2

4

ルートウィンドウから下のビュー階層を調査した後、フォトチューザーを閉じた後、viewControllerのビューがUITransitionViewの下に子として追加されていることがわかりました。そのため、解決策は、代わりにviewControllerのビューのスーパービューを削除することです。

- (void)imagePickerControllerDidCancel:(UIImagePickerController *)imagePickerController
{
    // Dismiss the image selection
    [pickerViewController dismissModalViewControllerAnimated:YES];
    [pickerViewController.view.superview removeFromSuperview];
}
于 2009-08-08T05:48:01.103 に答える
2

CJハンソンのソリューションがiPhoneで機能することに気づきました。

[pickerViewController.view.superview removeFromSuperview];

しかし、iPadではありません。通常の方法:

[pickerViewController.view removeFromSuperview];

iPadで動作します。現時点では両方に電話しましたが、問題なく機能しているようです。

[pickerViewController.view removeFromSuperview];
[pickerViewController.view.superview removeFromSuperview];

たぶん、より多くの知識を持っている人が、なぜこれが必要なのかを明確にすることができますか?

于 2012-06-22T23:19:47.797 に答える