views:

175

answers:

1

Hola! I have an issue I thought I would throw out to the S.O. world before I spent a lot of time on it.

Basically I have a requirement where I am getting a string of text which has inline images, like for a chat bubble in a UITableView. These images are akin to sparklines and/or emoticons.

Normally for something like this I would use a UIWebView and manually format the markup and load it, referencing the images in the app bundle.

But, I need it to be in a table view, and hence I have to load these things quickly.

I am thinking I need some sort of class that take a string with my image tokens in it, and generates a UIView with a UITextView on it, overlaid with the UIImageViews in the right places. Seems like a thorny problem. I have googled it quite a bit but nobody seems to have a good solution that I can find.

Does anybody know anything that might be a good approach to take better than I have laid out above? I can't be the first person to want to intermingle text inline with images in a UITableView, so I'm pretty sure there is a best practice I can follow.

+1  A: 

I would use a straight UIView, and do everything in CoreGraphics in the drawRect: method. If you go with your proposed method, you're creating an awfully complex view hierarchy, which, if its in a tableView, will slow scrolling.

Ben Gottlieb
I think that sounds like a good approach. Do you know offhand if it's possible to render an animated gif inline with the text? That sounds like it could be a problem using this approach.
Genericrich
that would require a bit more work. You could do it, but you'd basically have to redraw your entire view to match the framerate of the gif
Ben Gottlieb
Thanks Ben. I will update this question with details if I find anything interesting in trying this approach.
Genericrich