這個bug在iOS 7.0中可以通過修改textView委託方法來解決。
嘗試下面的代碼
- (void)textViewDidChange:(UITextView *)textView {
CGRect line = [textView caretRectForPosition:
textView.selectedTextRange.start];
CGFloat overflow = line.origin.y + line.size.height
- (textView.contentOffset.y + textView.bounds.size.height
- textView.contentInset.bottom - textView.contentInset.top);
if (overflow > 0) {
// We are at the bottom of the visible text and introduced a line feed, scroll down (iOS 7 does not do it)
// Scroll caret to visible area
CGPoint offset = textView.contentOffset;
offset.y += overflow + 7; // leave 7 pixels margin
// Cannot animate with setContentOffset:animated: or caret will not appear
[UIView animateWithDuration:.2 animations:^{
[textView setContentOffset:offset];
}];
}
}
您的問題將得到解決。
我面臨同樣的情況,我將uitextview製作爲可滾動的,它開始爲我工作。它有點奇怪,但爲我工作。 –