开发者

Detecting a click inside a UIWebView - not on a link

I want to enable some funct开发者_JAVA百科ionality that is triggered by clicking on the screen. the view of the screen is a UIWebView, and I'd like to be able to tell when the user clicks on it, though not when he clicks on a link inside of it, but any other place.

Any Ideas?

Tnx!


Have you looked at touchesBegan: / touchesEnded: in the UIResponder Class Reference


look at this code snippet. it might help you.

NSSet                   *touch;
CGPoint                 mTouchLocation;

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
touch = [event allTouches];
mTouchLocation = [[touches anyObject] locationInView:self.view];
}

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
 NSLog(@"touchesMoving");
}


- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
NSLog(@"touchEnded");
CGPoint newTouchLocation = [[touches anyObject] locationInView:self.view];  
}

touchesBegan is invoked when user touched the screen, touchesMoved when the user move the finger holding the screen and touchesEnded is when the touch is released.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜