美文网首页iOS酷玩技术分享
IOS7 UITextView 中文输入法上下跳动问题。

IOS7 UITextView 中文输入法上下跳动问题。

作者: gscc | 来源:发表于2015-06-01 12:08 被阅读1788次

解决方法

textView.layoutManager.allowsNonContiguousLayout = NO;

这句代码设置了 UITextView 中的 layoutManager(NSLayoutManager) 的是否非连续布局属性,默认是 YES,设置为 NO 后 UITextView 就不会再自己重置滑动了。

代码示例

UITextView *textView = [UITextView new];

textView.delegate = self;

textView.frame = CGRectMake(0, self.view.bounds.size.height/3, self.view.bounds.size.width, 100);

textView.backgroundColor = [UIColor lightGrayColor];

textView.font = [UIFont systemFontOfSize:20];

textView.text = @"ABC\nD\nD\nD\nD\nD\nD\nD\nEFG";

// textView.layoutManager.allowsNonContiguousLayout = NO;

[self.view addSubview:textView];

相关文章

网友评论

本文标题:IOS7 UITextView 中文输入法上下跳动问题。

本文链接:https://www.haomeiwen.com/subject/wbcdqttx.html