Genericrich
Genericrich

Reputation: 4641

Best Approach: iPhone String with Inline Images in UITableView

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.

Upvotes: 1

Views: 592

Answers (1)

Ben Gottlieb
Ben Gottlieb

Reputation: 85532

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.

Upvotes: 1

Related Questions