我使用以下代码实现选中文段开头和结尾中间的文字(offset为2):
//_questionDes 是 UITextView
UITextRange *range = [_questionDes textRangeFromPosition:[_questionDes positionFromPosition:_questionDes.beginningOfDocument inDirection:UITextLayoutDirectionRight offset:2] toPosition:[_questionDes positionFromPosition:_questionDes.endOfDocument inDirection:UITextLayoutDirectionLeft offset:2]];
[_questionDes setSelectedTextRange:range];
可是这种使用offset的办法感觉好笨啊,如果我要做更为精细的选中操作,难道我要去数位数?
请问各位,有木有更好更棒的方法?
少年,是不是这个意思?