问题描述
我正在开发一个需要视图控制器来显示大量希伯来语(非英语)文本的应用程序.
Im working on a an app that requires a view Controller to display a nice amount of hebrew(non-english) text in it.
文本是来自富文本文件的 AttributedString
我需要视图做 4 件事.
There are 4 things that I need the view to do.
平滑滚动
Smooth Scrolling
获取单词的范围,以便我可以自动滚动到它(例如 scrollRangeToVisible
)
Get the range of a word so I can auto-scroll to it (like scrollRangeToVisible
)
流畅地更改字体(我想使用 UISlider 更改字体)
Change the font smoothly (I'd like to use a UISlider to change the font)
快速加载
从某种意义上说,我正在寻找电子阅读器的功能,我只需要一列,我希望它滚动而不是页面.
In a sense Im looking for the capabilities of a e-reader just I only need one column and I want it to scroll not page.
我尝试过的事情有优点和缺点
Things I've tried and there pros and cons
常规 UITextView &滚动视图归类为 UITextView
优点:
- 轻松搜索和自动滚动
- 快速加载
- 流畅的字体变化
缺点:
- 非常不稳定的滚动
滚动视图中的 UILabel
优点:
- 搜索和自动滚动不容易,但易于管理
- 非常流畅的滚动
缺点:
- 非常断断续续的字体切换
- 加载缓慢
我唯一没有尝试过的(我能想到的)是 CoreText
The only thing I haven't tried (that I can think of) is CoreText
coreText 是要走的路吗?如果有一种方法可以让它更好地呈现大量希伯来语(非英语)文本,我宁愿使用 UITextView.
Is coreText the way to go? I would rather use a UITextView if there as a way to get it to render lots of hebrew (non-english) text better.
注意:我已经尝试在 UITextView 和 Selectable 上禁用编辑.
编辑 1
-(double)Height{
[layoutManager glyphRangeForTextContainer:textContainer];
NSLog(@"HEIGHT = %f",[layoutManager
usedRectForTextContainer:textContainer].size.height);
return [layoutManager
usedRectForTextContainer:textContainer].size.height;
}
推荐答案
我愿意
I would
实现 scrollRangeToVisible 本身就是一项很好的任务.我会使用 这些 方法.
Implementing scrollRangeToVisible will be a good task in itself. I would use one of these methods.
如果您只有字符范围并且需要计算字形范围,请使用 这些方法可能会有所帮助.
If you only have the character range and need to compute glyph range, one of these methods could help.
这不会很容易,但是一个非常好的项目:)
This won't be very easy, but a very good project :)
这篇关于UITextView vs UILabel+ScrollView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!