UITextview: Place focus on becomefirstresponder

不羁岁月 提交于 2020-01-05 12:13:27

问题


I have a UITextView which becomes first responder by tapping. The code looks like this.

UITapGestureRecognizer *recognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(editTextRecognizerTabbed:)];
recognizer.delegate = self;
recognizer.numberOfTapsRequired = 1;
[self.textViewNotes addGestureRecognizer:recognizer];

- (void) editTextRecognizerTabbed:(UITapGestureRecognizer *) aRecognizer;
{
    self.textViewNotes.dataDetectorTypes = UIDataDetectorTypeNone;
    self.textViewNotes.editable = YES;
    [self.textViewNotes becomeFirstResponder];
}

So when the user taps on the textview, the textview becomes the first-responder and the focus is on the end of the text. I want place the focus on the tapped position in the Text.

Any idea?

来源:https://stackoverflow.com/questions/25175934/uitextview-place-focus-on-becomefirstresponder

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!