views:

803

answers:

2

I would like to have formatted, clickable text and images inside a selected UITableViewCell. An example of the functionality I'm looking for can be seen in the iPhone Twitterrific app. When the user clicks on a cell, the cell is highlighted and the various links become highlighted and clickable.

I've seen the idea of using a UIWebView inside a UITableViewCell to handle formatting, but I'm unsure about this. Does that mean that every cell has to have it's own web view? I'm wondering about the expense and performance of such a method. Is there another way to get this functionality using Core Graphics?

I'm using custom drawing currently to draw my table view cells as described in atebit's blog post on fast scrolling.

+1  A: 

The first thing I would do is to checkout twitterific's old source code. And see if that version does what you are looking for.

I'm not sure how Hockenberry does it, but generally UIWebviews + UITableViewCells != fast scrolling.

My guess is that each cell does NOT contain a UIWebview until you click in it, when he quickly places a UIWebview in the cell to handle the text formatting. You then have a reusable UIWebview instance that you reuse but just change the content of repeatedly.

Corey Floyd
+2  A: 

Craig Hockenberry, author of Twitterrific, blogged about how he did that back in 2008:

http://furbo.org/2008/10/07/fancy-uilabels/

Basically, when the row is selected, he overlays UIButtons where the links are. It's imperfect, as sometimes the button won't fit in the same place the text does.

Hunter
Thanks, Hunter. I didn't realize the blog post was there or that the method used is such a hack. I wonder if that is how it is done in the latest version. I'd like to figure out a better way to do this.
sam
Yeah, it really does seem like a hack, I agree.
Hunter
Makes sense to use some UIButtons rather than a UIWebview as it would be a lot faster. It seems "hacky", but you could try to write a better cell to handle the awkward spacing ahead of time. Not sure how the performance would be doing that much parsing as you're scrolling. That may be why Hockenberry only parses a tweet if the user taps it, it saves a lot of processing work.
Corey Floyd