Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
iOS中的触摸事件转发_Ios_Objective C_Touch Event_Uiresponder_Uievent - Fatal编程技术网

iOS中的触摸事件转发

iOS中的触摸事件转发,ios,objective-c,touch-event,uiresponder,uievent,Ios,Objective C,Touch Event,Uiresponder,Uievent,我想在我的应用程序中显示一个UI组件,任何触摸事件都会将其忽略(尽管触摸组件本身会产生与触摸组件外部不同的结果) 我目前的解决方案是有一个自定义的UIWindow子类,它可以正确地处理触摸,并位于整个屏幕的顶部。但是,我不希望触摸被使用,而是希望被转发到它后面的任何UI元素(即,我希望触摸在窗口内触发某些内容,但仍然将事件转发到窗口后面的视图) 我尝试在-[MyWindow sendEvent:]中转发触摸事件的方式: NSUInteger superWindowIndex = [[UIAppl

我想在我的应用程序中显示一个UI组件,任何触摸事件都会将其忽略(尽管触摸组件本身会产生与触摸组件外部不同的结果)

我目前的解决方案是有一个自定义的UIWindow子类,它可以正确地处理触摸,并位于整个屏幕的顶部。但是,我不希望触摸被使用,而是希望被转发到它后面的任何UI元素(即,我希望触摸在窗口内触发某些内容,但仍然将事件转发到窗口后面的视图)

我尝试在-[MyWindow sendEvent:]中转发触摸事件的方式:

NSUInteger superWindowIndex = [[UIApplication sharedApplication].windows indexOfObject:self];
if (superWindowIndex == 0 || superWindowIndex == NSNotFound) {
    [super sendEvent:event];
} else {
    [[UIApplication sharedApplication].windows[superWindowIndex - 1] sendEvent:event];
}
然而,这并没有如我所希望的那样奏效

实现我的目标的最佳方式是什么?UIWindow是正确的方法吗?
谢谢

我的解决方案不是转发触摸,而是将您的UI组件包含在覆盖所有UI窗口的另一个视图中。然后,您可以在主UI之外的区域中添加TapSignature