Check the simplest method of touch on uiwebview

Source: Internet
Author: User
Check that the uiwebview has a touch action. My method is to use uitapgesturerecognizer. There are two key points. Please refer to my code (my code is in a uiviewcontroller): uitapgesturerecognizer * singletap = [[uitapgesturerecognizer alloc] initwithtarget: Self action: @ selector (handlesingletap :)];
[Self. View addgesturerecognizer: singletap];
Singletap. Delegate = self;
Singletap. cancelstouchesinview = no;

[Singletap release];

The third line is the first key, that is, the delegate of uitapguesturerecognizer must be set (generally we directly use initwithtarget without setting its delegate ).

The second key is to return yes in the following delegate method:

 

-(Bool) gesturerecognizer :( uigesturerecognizer *) gesturerecognizer author :( uigesturerecognizer *) othergesturerecognizer

{
Return yes;
}

By doing this, your uiwebview can respond to the touch event. You can use different uigesturerecognizer to meet your different requirements. (Complete the handlesingletap Method on your own ).

 

If you define the number of clicks to define your method:

Write:

-(Bool) gesturerecognizershouldbegin :( uigesturerecognizer *) gesturerecognizer {

Nslog (@ "% d", [gesturerecognizer numberoftouches]);
Return no;
}

Set according to your needs, and record the time difference to determine whether to click or double-click.

 

 

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.