UITextView中的firstRectForRange方法的CGRect在iOS 9中返回错误的帧位置

时间:2015-09-02 08:44:08

标签: ios uitextview cgrect uitextposition uitextrange

在iOS 5和iOS 9的iPod 5 / iPad中运行以下代码,输出如下

 UITextPosition *beginning = textView.beginningOfDocument;

UITextPosition *start = [textView positionFromPosition:beginning offset:range.location];
UITextPosition *end = [textView positionFromPosition:start offset:range.length];
UITextRange *textRange = [textView textRangeFromPosition:start toPosition:end];

CGRect rect = [textView firstRectForRange:textRange];
rect.size.width = rect.size.width + 2;
rect.origin.x = rect.origin.x - 1;

return [textView convertRect:rect fromView:textView.textInputView];
 Intent.EXTRA_STREAM, image i want to send);

CGRect rect = [textView firstRectForRange:textRange]; //问题

iOS 8输出:{x = 0,y = 201,宽度= 50,高度= 19}

iOS 9输出:{x = 0,y = 293,宽度= 50,高度= 19.4}

在iOS 9中更改了坐标和高度

UITextView中有任何变化吗?

查看附带的屏幕截图 Running in iOS 8

Running in iOS 9

0 个答案:

没有答案