iphone - UItextView 文本隐藏

标签 iphone ios uiscrollview uitextview

我是 notes.app 之类的应用。我将 UITextView 的 contentInset 设置为

myTextView.contentInset = UIEdgeInsetsMake(0, 25, 0, -25);
myTextView.contentSize = CGSizeMake(295, myTextView.contentSize.height);

但这似乎并没有像我预期的那样工作。隐藏了两个字符。

我明白了 got this

但是如果我设置

myTextView.contentInset = UIEdgeInsetsMake(0, 25, 0, 0);
myTextView.contentSize = CGSizeMake(295, myTextView.contentSize.height);

我得到的实际文本是

required

请帮忙。

最佳答案

fibnochi 你可以使用不同的方法来做到这一点。我已经在我的一个应用程序中使用过它并且运行良好

首先你需要得到 UItextView 的大小,它会承载所有的数据,为此你需要使用 NSString 类委托(delegate)函数​​

NSString* str = @"Your Entire string will come here";

CGSize size = [str sizeWithFont:[UIFont systemFontOfSize:17.0] constrainedToSize:CGSize(295, any large digit for maximum height say 10000) lineBreakMode:UILineBreakModeWordWrap];

textView.contentSize = size;

这是否能解决您的问题。请告诉我

关于iphone - UItextView 文本隐藏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13800612/

相关文章:

iphone - 从 xib 中提取 UI 项目?

iphone - 为什么通过Google API上传文档会在http请求 header 中出现错误

ios - 从 UITableViewCell 中删除 UILabels 并再次添加它们

iphone - ScrollView 图像向左滚动后是否从内存中删除?

ios - 滚动 UIScrollView 时不会更新 UI 元素

iphone - 如何检测 UIKit 对象的泄漏?

ios - UIButton 没有正确定位自己并且没有出现在某些设备中 - Objective C

objective-c - 编译器错误阻止 iOS 项目编译

ios - 神奇的记录删除一对多关系所有 child

iphone - UIS ScrollView 。内部有许多 UIView 的页面 Controller