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.