我想开发一款App。可以检测用户是否触摸特定view
,以便发生某些操作。我实施了SimpleOnGestureListener
来检测和收听用户'触摸整个屏幕。我现在的问题是,下面发布的方法,给出了相同视图的不同坐标,我不知道应该使用哪一个来与SimpleOnGestureListener
给出的坐标进行比较。
提供视图坐标的方法:
tv1.getLocalVisibleRect(tv1Rect);
tv1.getLocationOnScreen(tv1LocOnScreen);
tv1.setText("xCords: "+tv1.getX()+", yCords: "+tv1.getY());
答案 0 :(得分:1)
要查看某个视图是否包含所触及的点,您可以使用
CGRectContainsPoint(your view frame, the CGPoint of the tap)
您可以通过
从手势识别器获取水龙头的CGPointCGPoint location = [recognizer locationInView: view which the recognizer is attached to];