Some Questions Concerning Text
So I’ve been building test apps, finalizing grids and so forth getting ready to push this issue out and in my testing I’ve come across a snag when it comes to displaying text in this issue. I’ve gone back and forth about what to do and so I thought the best thing to do would be to make a sample app today so you can better see what I’m talking about, maybe I can get some opinions or find a better solution.
All along I had decided to make this app have all native text and I figured I would do that by having the text by html and displaying it in webviews. I had done this before (the last app had this for the text only views), but the performance was pretty bad so I knew I couldn’t have it be the main option. I was sure this time around, if I searched hard enough or maybe Apple fixed the performance and it would be a viable option now. Well I’ve been going over this for weeks now and I don’t think it is.
The sample app is just a webview and a label using custom fonts, (I included free fonts so as to not get myself in trouble). It’s as simple as can be and if you run tests on it, you can see that it allocates almost double of what a view would be if the text was images instead. What’s worse is that if you put the app in the background (close the app) you will see that it doesn’t release barely anything. Now I could be doing something wrong, but I don’t think I am. If somebody sees something that knows better, please let me know.
I’ve looked into other options. CoreText is a mess and not a viable option for this issue, since the main point of it is to make code that can be straightforward and simple to use. Nothing about CoreText is direct or simple. Displaying a PDF or doc allocates even more, and UITextView doesn’t come with many options. As of this moment I’m going to be using images for the text again. It’s not ideal, but I’m not going to sacrifice the app just to stay with an ideal. Another advantage to using images that you can’t with a webview is that I can lazily load them so that the performance is better. This is what I did in the recent issue of Port Magazine. Only the first couple paragraphs load right away so that the app doesn’t have to load much when you first turn to that page. Then in a second or two, the rest of the text loads in the background. Webviews aren’t thread safe so everything has to wait until the html is done loading.
When I release the source code I will provide other options, and you can look at this sample code as a good starter if this is the way you want to go. So please download and check it out. If you have any opinions or solutions to try, I’d love to hear it.