iOS7下UITextView最后一行光标位置问题
来源:互联网 发布:sql virtual table 编辑:程序博客网 时间:2024/06/05 06:53
iOS7下UITextView会出现一个小小的问题,光标在最后一行的时候会被遮挡
- (void)textViewDidChange:(UITextView *)textView{ if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0f) { 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]; }]; } }}
参考资料来自stackoverflow
0 0
- iOS7下UITextView最后一行光标位置问题
- UITextView光标位置在中间的问题
- UITextView的用法及技巧(ios7下光标bug解决方案)
- UITextView的用法及技巧(ios7下光标bug解决方案)
- UITextView光标位置
- UITextView获取光标位置
- iOS UITextView 光标位置
- iOS UITextView 光标不在第一行,不在顶部的问题
- datagridview 光标最后一行
- IOS UITextView光标位置在中间的问题
- IOS UITextView 光标的位置,大小,宽度,高度设置问题
- iOS开发~UITextView光标不在起始位置问题
- IOS UITextView光标位置在中间的问题
- UITextView光标位置的设置
- 获取 UITextView 的光标位置
- 设置UITextView,UITextField光标位置
- UITextView汉字光标问题
- iOS UITextView 光标问题
- Oracle数据库学习(1)--数据库的创建
- 关于pos终端功能的简要总结
- Android开发中如何结束所有的activity
- 荣耀3c四核已经发布
- 码农提高工作效率
- iOS7下UITextView最后一行光标位置问题
- js显示日期和时间
- c3 Threads - Returning Infomation From a Thread
- 练习,体重测试是否超重
- perl常用的内置特殊变量
- 高效程序员的 7 个共同特征
- ios NSString 去除空格和回车
- Mac下Android Studio搭建
- STL 之adjacent_find, merge,inplace_merge