1
votes

I have added a UIView / UIWindow on top of the screen.

UIWindow *statusBarWindow = [[UIWindow alloc] initWithFrame:[UIApplication sharedApplication].statusBarFrame];
statusBarWindow.windowLevel = UIWindowLevelStatusBar + 1;
statusBarWindow.userInteractionEnabled = NO;
[statusBarWindow makeKeyAndVisible];

But these views should not be touchable and touches on it should trigger the touch on the view below these. Right now the touches don't go through when I add this view and nothing happens.

How can I let a UIView/UIWindow not handle touch events?

I tried .userInteractionEnabled = NO but that didn't work. Thanks!

1
Are you adding a second UIWindow to the application? If so you shouldn't be "Unless an app can display content on an external device screen, an app has only one window." (developer.apple.com/library/ios/#documentation/uikit/reference/…)Ben Avery
That guidance has changed: "Although you can create additional windows on the device’s main screen, extra windows are commonly used to display content on an external screen"Matt Comi

1 Answers

1
votes

One way is to override -hitTest:withEvent: to return NO in the view that you don't want to respond to touches.

It's probably best to use a view that's not a window for this so that the superview's hitTest:withEvent: method will continue searching the view hierarchy and find the next view at that location. (Windows don't have superviews, and I'm not sure that the event manager will check other windows for the same event.)