現在我已經發現長按中的UITextView現在中的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);
}
,我應該怎麼做才能讓字其中有長按的內容,並獲得一個矩形準備展示PopOver的單詞?
請檢查http://stackoverflow.com/questions/8811909/getting-the-word-touched-in-a-uilabel-uitextview/21577829#21577829。我已經使用過'UITapGestureRecognizer',你可以用'UILongPressGestureRecognizer'替換它。 – TheTiger 2014-02-05 12:54:58