How to set cursor position for non editable UIText

2019-07-18 16:27发布

I have not editable UITextView. When it get focus, the cursor position is on the begining. How can I set position of cursor? (I am using iPhone devise with Braille keyboard and when not editable UITextView get focus, I have text from the very begining of it, so I need to set position of cursor.)

标签: iphone ios
1条回答
迷人小祖宗
2楼-- · 2019-07-18 17:01

If you want to set cursor position at the end then use this delegate like this::

- (void)textViewDidChangeSelection:(UITextView *)textView{
textView.text =[NSString stringWithFormat:@"%@",textView.text];
}

- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text{
return NO;
}

Remember one thing set UITextView property to yes for displaying cursor

查看更多
登录 后发表回答