问题
Im working on a an app that requires a view Controller to display a nice amount of hebrew(non-english) text in it.
The text is an AttributedString from a Rich Text File
There are 4 things that I need the view to do.
Smooth Scrolling
Get the range of a word so I can auto-scroll to it (like
scrollRangeToVisible
)Change the font smoothly (I'd like to use a UISlider to change the font)
Load quickly
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
Regular UITextView & Scrollview Classed as UITextView
PROS:
- Easy search and auto-scroll
- Quick load
- Smooth font changing
CON:
- Very choppy scrolling
UILabel in a ScrollView
PROS:
- search and auto-scroll is not easy but manageable
- Very smooth scrolling
CON:
- Very choppy font switching
- Slow loading
The only thing I haven't tried (that I can think of) is CoreText
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.
Note: I have already tried disabling editing on the UITextView and Selectable.
EDIT 1
-(double)Height{
[layoutManager glyphRangeForTextContainer:textContainer];
NSLog(@"HEIGHT = %f",[layoutManager
usedRectForTextContainer:textContainer].size.height);
return [layoutManager
usedRectForTextContainer:textContainer].size.height;
}
回答1:
I would
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 :)
来源:https://stackoverflow.com/questions/30651858/uitextview-vs-uilabelscrollview