How to move cursor of UITextView to TOUCHED LOCATION?

前端 未结 2 962
予麋鹿
予麋鹿 2021-01-01 04:35

The goal of my question is making note app like iOS\'s. The point of iOS\'s note app is that they provide to user to use hyper link or phone number link or email address as

2条回答
  •  说谎
    说谎 (楼主)
    2021-01-01 04:55

    - (void) editTextRecognizerTabbed:(UITapGestureRecognizer *) aRecognizer
    {
        if (aRecognizer.state==UIGestureRecognizerStateEnded)
        {
            //Not sure if you need all this, but just carrying it forward from your code snippet
            textview.editable = YES;
            textview.dataDetectorTypes = UIDataDetectorTypeNone;
            [textview becomeFirstResponder];
    
            //Consider replacing self.view here with whatever view you want the point within
            CGPoint point = [aRecognizer locationInView:self.view];
            UITextPosition * position=[textView closestPositionToPoint:point];
            [textView setSelectedTextRange:[textView textRangeFromPosition:position toPosition:position]];
        }
    }
    

提交回复
热议问题