Open zs1040466634 opened 4 years ago
请问您是怎么解决的
请问您是怎么解决的
具体记不太清楚了,你看一下以下代码对你有没有帮助 :)
(void)textViewDidBeginEditing:(YYTextView )textView { NSRange range = textView.selectedRange; if (!(range.location == 0 && range.length == 0)) { YYTextRange textRange = [YYTextRange rangeWithRange:range affinity:YYTextAffinityBackward]; CGRect rect = [self.yyTextView.textLayout rectForRange:textRange]; if (rect.origin.y + rect.size.height > kScreenHeight - [YYTextKeyboardManager defaultManager].keyboardFrame.size.height - KStatusBar_Navigation_Height) { //顶部留一点图片以及文字编辑区域 [self.yyTextView setContentOffset:CGPointMake(0.0f, rect.origin.y + rect.size.height - 32.0f - 21.0f) animated:NO]; } } }
(void)textViewDidChange:(YYTextView )textView { UITextRange selectRange = [YYTextRange rangeWithRange:textView.selectedRange affinity:YYTextAffinityBackward]; [textView setSelectedTextRange:selectRange];
}
好的,谢谢
1.插入了一张比较短和比较长的图片,然后在两张图片中间输入文字,然后在删除文字时,视图会向上滚动,光标会上移不在可见区域内 2.如果textView中最后一张是图片,点击图片弹出键盘,视图不会跟随上移,键盘会遮挡图片