iOS获得UITextView当前光标所在的位置.很简单:
定义两个变量
{
UITextView * _inputTV;
NSRange _range;
}
初始化textView:
_inputTV = [[UITextViewalloc] initWithFrame:CGRectMake(15,10, kScreenWidth-30, 130)];
_inputTV.delegate =self;
_inputTV.backgroundColor = [UIColorclearColor];
_inputTV.textColor = [UIColorblackColor];
[self.view addSubview:_inputTV];
//当前光标所在的位置:
_range = _inputTV.selectedRange;