1

我在屏幕顶部添加了一个 UIView / UIWindow。

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

但是这些视图不应该是可触摸的,并且触摸它应该触发对这些视图下方的触摸。现在,当我添加此视图时,触摸没有通过,并且没有任何反应。

如何让 UIView/UIWindow 不处理触摸事件?

我试过.userInteractionEnabled = NO了,但没有用。谢谢!

4

1 回答 1

1

一种方法是覆盖-hitTest:withEvent:以返回NO您不想响应触摸的视图。

最好为此使用不是窗口的视图,以便超级视图的hitTest:withEvent:方法将继续搜索视图层次结构并在该位置找到下一个视图。(Windows 没有超级视图,我不确定事件管理器是否会检查其他窗口是否有相同的事件。)

于 2013-07-09T21:57:27.280 回答