如何设置不可编辑的UITextView的光标位置? [英] How to set cursor position for non editable UITextView?
本文介绍了如何设置不可编辑的UITextView的光标位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我没有可编辑的UITextView.当它获得焦点时,光标位置在开始处.如何设置光标的位置?(我正在使用带盲文键盘的iPhone devise,当无法编辑的UITextView成为焦点时,我从一开始就有文字,因此我需要设置光标的位置.)
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.)
推荐答案
如果要在末尾设置光标位置,请使用此委托,如下所示::
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;
}
记住一件事,将UITextView属性设置为yes,以显示光标
Remember one thing set UITextView property to yes for displaying cursor
这篇关于如何设置不可编辑的UITextView的光标位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文