Reputation: 4751
I am using the following code for determine how much text can fit in text view without scrolling. It works fine with iOS 6, but it doesn't work with iOS 7. The text view is valid (not nil), there is text in text view, but start and end are nil. Any help would be appreciated.
-(NSRange)visibleRangeOfTextView:(UITextView *)textView {
CGRect bounds = textView.bounds;
UITextPosition *start = [textView characterRangeAtPoint:bounds.origin].start;
UITextPosition *end = [textView characterRangeAtPoint:CGPointMake(CGRectGetMaxX(bounds), CGRectGetMaxY(bounds))].end;
NSRange range = NSMakeRange([textView offsetFromPosition:textView.beginningOfDocument toPosition:start],
[textView offsetFromPosition:start toPosition:end]);
return range;
}
Upvotes: 1
Views: 885
Reputation: 4091
Set contentInset for your textView,
[textView setContentInset:UIEdgeInsetsMake(-45, 0, 5,0)];
Upvotes: 1