UITextView draws incorrectly on iOS 7

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]; 

UITextView to draw incorrectly from below. IOS 7 doesn't seem to increase contentSize when scrollEnabled is false. However, this code will work fine in iOS 6. Is there something I can do to fix this? I need the scrolling to be disabled, otherwise it will scroll back when the text is added, which is not what I want.

+6
source share
1 answer

Get in the same problem. Here is the ugly temporary hack of FWIW:

 NSAttributedString* text = textView.attributedText; _textView.text = @""; _textView.attributedText = text; 

It is like resizing and redrawing.

+1
source

Source: https://habr.com/ru/post/954196/


All Articles