Handling touches inside UIWebview

前端 未结 10 2115
感情败类
感情败类 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:51

    No subclassing needed, just add a UITapGestureRecognizer :

    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(didTapMethod)];
    [tap setNumberOfTapsRequired:1]; // Set your own number here
    [tap setDelegate:self]; // Add the  protocol
    
    [self.myWebView addGestureRecognizer:tap];
    

    Add the protocol in the header file, and add this method:

    - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
    {
        return YES;
    }
    

提交回复
热议问题