gpt4 book ai didi

iphone - 如何响应 UIWindow 中的触摸事件?

转载 作者:太空狗 更新时间:2023-10-30 03:40:01 24 4
gpt4 key购买 nike

是否可以在应用程序委托(delegate)或其他任何地方处理关键 UIWindow 中的触摸事件?

如有任何帮助,我们将不胜感激。

最佳答案

UIWindow 中有一个方便的包罗万象的方法,称为 sendEvent:,它可以查看事件处理管道开始附近的每个事件。如果你想做任何非标准的附加事件处理,这是放置它的好地方。像这样:

- (void)sendEvent:(UIEvent *)event {
if ([self eventIsNoteworthy:event]) [self extraEventHandling:event];
[super sendEvent:event]; // Apple says you must always call this!
}

文档:UIWindow class reference | iOS event delivery docs

This blog post还提到了如何覆盖 hitTest:withEvent: 以在事件绑定(bind)到 View 层次结构中的目标叶 subview 之前捕获一些事件。如果需要,您还可以在 UIWindow 对象上覆盖该方法。

关于iphone - 如何响应 UIWindow 中的触摸事件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1532778/

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