Search code examples
iphoneobjective-ciostouchuiwindow

Detect touch event on global UIWindow object


I have created a UIWindow global object for my application like

#define APP_DELEGATE_WINDOW ((UIWindow*)((AppDelegate*)[[UIApplication sharedApplication] delegate])).window

Now in one UIViewController, I m adding a subview with a transparent background to the APP_DELEGATE_WINDOW.

I want such a functionality that, when I touch on the transparant background added on the APP_DELEGATE_WINDOW, I want to close the subview.

How can I detect touch on APP_DELEGATE_WINDOW, so that on that Touch event, I can close the view with its subviews.


Solution

  • Now in one UIViewController, I m adding a subview with a transparent background to the APP_DELEGATE_WINDOW.

    You could add a UITapGestureRecognizer to the subview with the transparent background. Then in the handler of the gesture recognizer, you would remove the view controller with its views.