【发布时间】:2011-12-02 13:04:59
【问题描述】:
我有一个带有文本字段、按钮和表格的 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];
}
谢谢。
【问题讨论】:
标签: ios cocoa-touch hittest touch-event