NSTextContainer的usedRectForTextContainer返回不正确的高度
我试图得到所需矩形的大小显示给定的文本容器中的文本与下面的代码:
s = [manager usedRectForTextContainer:container].size;
我期望文本是在多行中,但是在行的末尾切断并且不显示下一行中的内容。 只有当有一些额外的字符时才会发生这种情况; 在大约60个字符的行中,下一行将显示10或15左右的剩余,但是不显示。
这可能是一个插入问题? 也许文字包装? 我真的不确定,因为我是iOS和UI编程的新手。
编辑:在上面的代码中,manager是一个NSLayoutManager
,而容器是一个NSTextContainer
。
我敢肯定,这是输出这个问题,因为在这个函数调用之后,如果我将s的值更改为我所期望的值,我将显示整个string的预期布局。
有关布局pipe理器的信息是
<NSLayoutManager: 0xd203f60> 1 containers, text backing has 140 characters Currently holding 140 glyphs. Glyph tree contents: 140 characters, 140 glyphs, 1 nodes, 32 node bytes, 384 storage bytes, 416 total bytes, 2.97 bytes per character, 2.97 bytes per glyph Layout tree contents: 140 characters, 140 glyphs, 62 laid glyphs, 2 laid line fragments, 3 nodes, 96 node bytes, 856 storage bytes, 952 total bytes, 6.80 bytes per character, 6.80 bytes per glyph, 31.00 laid glyphs per laid line fragment, 476.00 bytes per laid line fragment
我希望在这种情况下有三行,但看起来只有两行碎片,也许问题出在我的布局pipe理器中?
- 如何在UINavigationBar标题上设置字距(字符间距) – Swift或Objective-C
- 键盘退出后,使inputAccessoryView可见
- 在iPhone 4英寸的屏幕上,模拟器显示3.5英寸的屏幕。 请检查屏幕截图。 可能是什么问题?
- 在presentViewController之后,模态viewcontroller UI没有响应:animated:completion:
- 使UITableView看起来更像是一个“常规”的表,有多列
- 更新文本字段ui在迅捷的ios
- 对于更便宜的颜色:UIView或UIImage
- 使用iOS 6应用程序的iOS 6主题
- video作为iOS背景最有效的方法