Ora ho già rilevato lungo tap in UITextViewGet parola lungo tap in una parola di UITextView
- (void)viewDidLoad
{
[super viewDidLoad];
UILongPressGestureRecognizer *LongPressgesture = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongPressFrom:)];
[[self textview] addGestureRecognizer:LongPressgesture];
longPressGestureRecognizer.delegate = self;
}
- (void) handleLongPressFrom: (UISwipeGestureRecognizer *)recognizer
{
CGPoint location = [recognizer locationInView:self.view];
NSLog(@"Tap Gesture Coordinates: %.2f %.2f", location.x, location.y);
}
Ora, come devo fare per ottenere contenuti di parola che ha premuto a lungo, e ottenere un rettangolo di che parola da preparare per mostrare il PopOver?
Si prega di verificare http://stackoverflow.com/questions/8811909/getting-the-word-touched-in-a-uilabel-uitextview/21577829#21577829. Ho usato 'UITapGestureRecognizer' puoi sostituirlo con' UILongPressGestureRecognizer'. – TheTiger