我有一个UITextView它允许一些RichTextEditing。我希望每当用户点击文本的某个位置时,光标应该移动到那里,并且应该从该位置开始编辑。开始编辑用户抽头位置上的UITextView
问题: 会发生什么事,当我拖动光标以我所选择的任何位置,写的东西马上光标移动到的UITextView的文本的结束和开始写作。我想要编辑从用户点击位置或光标位置开始。
以下是我正在使用的功能。
-(void) textViewDidBeginEditing{
//Can set the cursor or selected Range of textView here or tap gesture recognizer required?
return true;
}
-(void) textViewDidEndEditing{
return true;
}
-(void) textViewDidChangeTextInRange:(UITextView *) textView range:(NSMakeRange) range replacementText: (NSString *) text{
//Sets attributed text of my TextView based on my input AccessoryView
if(textView.text.lenght > range.location){
//This is my point of concern where I want to start the editing
}
return false;
}
对不起,我的代码错误。我现在无法访问我的objectiveC代码。这是写给你一个想法,我在做什么。 我发现这个,但不能得到它的工作。我正在使用它正在使用的字段的UITextView。 how to move cursor in UITextField after setting its value
请亲引导我。