哪种方法给出了GestureDetector给出的精确坐标

时间:2014-05-29 19:12:24

标签: android ios gesture

我想开发一款App。可以检测用户是否触摸特定view,以便发生某些操作。我实施了SimpleOnGestureListener来检测和收听用户'触摸整个屏幕。我现在的问题是,下面发布的方法,给出了相同视图的不同坐标,我不知道应该使用哪一个来与SimpleOnGestureListener给出的坐标进行比较。

提供视图坐标的方法:

tv1.getLocalVisibleRect(tv1Rect);
tv1.getLocationOnScreen(tv1LocOnScreen);
tv1.setText("xCords: "+tv1.getX()+", yCords: "+tv1.getY());

1 个答案:

答案 0 :(得分:1)

要查看某个视图是否包含所触及的点,您可以使用

CGRectContainsPoint(your view frame, the CGPoint of the tap)

您可以通过

从手势识别器获取水龙头的CGPoint
CGPoint location = [recognizer locationInView: view which the recognizer is attached to];