I want to develop an App. that can detect if the user touches a specific view
, so that certain action to happen. I implemented SimpleOnGestureListener
to detect and listen users' touches across the screen. My problem now is, the below posted methods, give different coordinates of the same view and i do not know which one should i use to compare with the coordinates given by the SimpleOnGestureListener
.
Methods that give coordinates of the views:
tv1.getLocalVisibleRect(tv1Rect);
tv1.getLocationOnScreen(tv1LocOnScreen);
tv1.setText("xCords: "+tv1.getX()+", yCords: "+tv1.getY());
To find out if a view contains the point touched you can use
CGRectContainsPoint(your view frame, the CGPoint of the tap)
You can get the CGPoint of the tap from a gesture recognizer by
CGPoint location = [recognizer locationInView: view which the recognizer is attached to];