Show large amount of attributed text efficiently using textkit without using paging - ios

I have a large text file and I need to show it continuously, like one can do in textview. However, the rendering of the text takes a lot of time in UILable/UITextView. I have tried working with TextKit to only render the portion of the text visible on screen but was unsuccessful. TextContainer's height need to be set depending on the content height for it to work and that is no better than using UITextView or UILabel.
Is there a way to only render the portion of the text that is visible on screen without using paging. Please share your thoughts on if that is achievable with high performance.
thanks

Related

Is a UIWebView the best way to display formatted text in iOS?

I want to display formatted text in my iOS app and I have a lot of it (about as much text as a medium sized wikipedia entry) is a WebView with html the best way to display formatted text or is there a better way? I read on stackOverflow that WebViews suck a lot of memory, is that true? How does wikipedia display all of its text in its iOS app?
The main reason you should use UITextView or UILabel to display formatted text is that there is no ultimate way to get content bounds at the first time it is drawn in UIWebView.
You can use UIKit object whichever you can render NSAttributedString such as UITextView or UILabel.
If your content is html you can convert it to NSAttributedString.
I ended up using a WKWebView with a contrained height and width. That way I could load the HTML without any additional set up and I didn't run into any problems with the web views bounds.

How to display a couple pages of text in swift ios

I've got an information page which has about 3 pages worth of text to display.
What would be the best method to display all this text in an iOS application coded in swift?
I have been trying to do it with scroll view but I can't fit all the text into one label on one screen. And all the tutorials I'm following say to set the scroll view to the size of the label. But the thing is my text is so long that it would fill the screen several times.
How could this be accomplished so that no matter which device size screen it's being viewed on it will fit all my text and be scrollable vertically?
I can't seem to get it working with a scrollview :/
Put the content in an HTML file, and render it using WKWebView: https://developer.apple.com/library/ios/documentation/WebKit/Reference/WKWebView_Ref/index.html#//apple_ref/occ/cl/WKWebView
You can make a text view non editable.
I have this problem also.. Maybe you could use table view and add contents programmatically.. hope it could add to your imagination.

RichText label or 'flow' layout for text in iOS (Xamarin/MonoTouch)

I am trying to repduce a similar sort of layout as in the screenshot below from the Digg app..
Notice that each list entry has a title in bold followed by the source, posted time and finally if there is enough space the start of the description line.
The question is what is the best way to achieve this in iOS? With some posts having longer titles than others I cannot simply say that the title label is 40px high and then place the Source label at 45 as the title will sometimes be longer and sometimes shorter.
Do I have to calculate the height of the label based on its contents before arranging the layout or is there some better way of doing this in iOS so that the views 'below' are automatically moved down?
Another alternative would be some sort of rich text label that I could add all the text to and have it automatically wrap round moving the later text down but I cannot find any sort of control in standard iOS / Xamarin (MonoTouch).
Any pointers would be greatly appreciated?
If you are using a storyboard the simplest way to achieve this result is to define different prototype cells. For example, you could define four different prototype cells, each one with a different layout like those shown in the example picture you provided. You can dequeue the appropriate cell based on the content you want to display so there is no need to adjust the layout in the code.
If you are doing everything in code, it's a lot more complicated since you have to build your own "layout engine" to adjust size and position of the views in your cell. You can have a look at XibFree or use MonoTouch.Dialog as suggested in the comments.

iOS - how to handle a case when there is a long text area in an app screen?

I am having a usability issue where in an app screen, there may be too much text and I have nowhere to put that text.
I am attaching a screen shot of my screen. You see how the text on top has more text, but there is no room to put that text. So the text just ends in ....
What is the common way people handle this kind of a situation?
Thanks!
Redesign your UI so you have more room for that text. Maybe your content will need to scroll. You will need to change that label so that the max number of lines is greater (or 0 for unlimited), and make the frame larger to accomodate more lines. You can also reduce the font size a little to decrease how much extra space you'll need to give it.
If you really wanted to, you could use a UITextView for that text, which allows the text to scroll easily (it's a UIScrollView subclass). Then you could just scroll that text, though it wouldn't be very good UI and you would still want it to be more than one line, because scrolling when only one line is visible at a time would make it hard to read.

How to scroll cut off text iOS tableview like a moving banner

I have a tableview with dynamic data from a parsed xml file. I have set a default font size, and for most entries, it works okay. However, some have an entry that seems to be cut off.. and Apple simple adds "..." to the end.
Is there a way I can implement something like a slowly scrolling banner to accommodate this? And if not, is there a way I can make the text fit if it exceeds the size without making a global change to all entries?
I think for the slowly scrolling banner you would have to implement that yourself by animating your views.
If you don't expect your text to exceed the size by that much you could try using minimumScaleFactor in ios6:
[label setMinimumScaleFactor:.75f];
or minimumFontSizeSize for < ios6.
These essentially shrink the text to fit the frame.
p.s. you can configure these in interface builder

Resources