I wanna get the all rects from UITextRange. you know, if UITextView line wrap, the UITextRange will be represented by more than 1 CGRect. in iOS 6.0, there is a method as "selectionRectsForRange:", so you can get the all CGRects. But in older version, there is only a method "firstRectForRange:" I checked the APIs documents again and again, but i find nothing.
My code likes blow:
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];
//(in iOS 6.0)
NSArray *array = [textView selectionRectsForRange:textRange];
for (int i=0; i<[array count]; i++) {
NSLog(@"rect array = %@", NSStringFromCGRect([[array objectAtIndex:i] rect]));
}
// (in earlier version)
CGRect rect = [textView firstRectForRange:textRange];