我想启用一些通过点击屏幕触发的功能。屏幕的视图是一个UIWebView,我希望能够告诉用户何时点击它,但不是当他点击其中的链接,而是点击任何其他地方时。
任何想法?
TNX!
答案 0 :(得分:0)
答案 1 :(得分:0)
查看此代码段。它可能对你有帮助。
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,当用户移动手指按住屏幕时触摸移动触摸,触摸触摸时触摸触摸释放。