这段代码:
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
底部绘制不正确。似乎iOS 7没有增加contentSize
whenscrollEnabled
为false。不过,这段代码在 iOS 6 中可以正常工作。我可以做些什么来解决这个问题吗?我需要禁用滚动,否则添加文本时它将滚动回顶部,这不是我想要的。