This code:
UITextView *textView = [[UITextView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, width, 80.0f)];
[textView setText:@"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."];
[textView setEditable:NO];
[self addSubview:textView];
[textView setScrollEnabled:NO];
[textView setText:[textView.text stringByAppendingFormat:@"\nHello!"]];
[textView setScrollEnabled:YES];
Will cause the UITextView
to draw improperly at the bottom. It seems that iOS 7 does not increase the contentSize
when scrollEnabled
is false. This code would work fine in iOS 6, though. Is there something that I can do to fix this? I need scroll disabled, otherwise it will scroll back to the top when the text is added, which is not what I want.
Ran into the same problem. Here's an ugly temporary hack FWIW:
NSAttributedString* text = textView.attributedText;
_textView.text = @"";
_textView.attributedText = text;
This seems to force the resizing and redraw.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With