0
我有一个带有文本字段,按钮和表的UIWindow。 我希望能够跟踪屏幕上的所有触摸,然后将它们转发到正在触摸的元素。只将触摸事件转发给正在触摸的视图
我看了一下在Apple documentation覆盖sendEvent
但我还是不明白:
- 如何使用
hitTest
检索元素被触摸 - 如何推进触摸
这是迄今为止我所拥有的。
- (void) sendEvent:(UIEvent *)event
{
for (UITouch *touch in [event allTouches])
{
/* Get coordinates of touch */
CGPoint point = [touch locationInView:self];
/* Get subview being touched */
/* something like this???
UIView *receiver = [self hitTest:point withEvent:event];
*/
/* Forward touch event to right view */
/* how??? */
}
[super sendEvent:(UIEvent *)event];
}
谢谢。
这工作,但倒是有从来没有传递给任何事物的视图,他们只是被转发。我想知道是否有可能“复制”事件并将它们传递给多个视图(在我的情况下,顶视图和被触摸的视图)。 –
如果你只是删除'return'语句会发生什么? – Anno2001