Handling touches inside UIWebview

前端 未结 10 2078
感情败类
感情败类 2020-11-30 22:46

I have created a subclass of UIWebView , and have implemented the touchesBegan, touchesMoved and touchesEnded methods.

10条回答
  •  攒了一身酷
    2020-11-30 23:39

    Following on from what Unfalkster said, you can use the hitTest method to achieve what you want, but you don't have to subclass UIWindow. Just put this in your web view subclass. You will get a compile time warning but it does work:

    - (void)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
        if (event.type == UIEventTypeTouches) {
    
            // get location info
            CGFloat x = point.x;
            CGFloat y = point.y;
    
            // get touches
            NSSet *touches = [event allTouches];
    
            // individual touches
            for (UITouch *touch in touches) {
    
                if (touch.phase == UITouchPhaseBegan) {
                    // touches began
    
                } else if (touch.phase == UITouchPhaseMoved) {
    
                }
    
                // etc etc
            }
        }
    
        // call the super
        [super hitTest:point withEvent:event];
    }
    

    Hope that helps!

提交回复
热议问题