Question

I have added some links to my UITextView using NSAttributedString,and I want to show user a 'note' when they click the link.The problem is I don't know how to get the position of the tap where user tap to open the link.

Was it helpful?

Solution

override hitTest:withEvent method

signature

- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event

Above method is supplied with CGPoint which is the location of touch.Create a CGPoint class property and store the touch-location in it.

@property (nonatomic,assign) CGPoint previousTouch;

- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event{
   self.previousTouch = point;
   return [super hitTest:point withEvent:event];
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top