Making text in a table row html aware?
I'm currently using the label object to render text from a twitter feed inside a table row and I noticed that the content renders as "plain" text. I'd like any links inside to become active and link out via Safari. Should I be using a webview instead so any html will render automatically? And will a webview render properly in a table row?
Thanks!
5 Answers
-
Accepted Answer
I did it the way nick was talking using this code to parse the the text and return the link.
I then used a simple if statement to add a hasChild and a property to the row. Made the whole row the link
function matchLink(text) { var exp = /(b(https?|ftp|file)://[-A-Z0-9+&@#/%?=~_|!:,.;]*[-A-Z0-9+&@#/%=~_|])/ig; return text.match(exp); }
-
I tried to do this recently and, short of parsing all the text yourself to extract URLs and create custom rows, your only option is to put the text in a webview in each row of the tableview.
I had lots of text with complex CSS which resulted in a number of display anomalies when scrolling the tableview, but you may have more luck with a twitter feed.
-
I'm working on something similar. My plan right now is to parse the url and extract it from the tweet, then display just the plain text in a tableview row. Then I'll pop a hasChild on there and link the whole row to the URL.
This solution only works for content with one URL associated with it (e.g. many tweets), and isn't stylistically the same as twitter.com or the style I think you're going for, but I think it might work ok for this particular use case.
-
I tried putting a webView in there but didn't get anything in return: (createWebview and assigned the tweet content to the html variable). Not sure what I'm doing wrong there but I guess it's a moot point until I figure out how to parse the links in the text as Nick is planning to do. So at this point it looks like I have two tasks ahead of me before this is going to work. If anyone has any good code to parse out the links I'd be ever so greatful.
-
I tried putting a webView in there but didn't get anything in return: (createWebview and assigned the tweet content to the html variable). Not sure what I'm doing wrong there but I guess it's a moot point until I figure out how to parse the links in the text as Nick is planning to do. So at this point it looks like I have two tasks ahead of me before this is going to work. If anyone has any good code to parse out the links I'd be ever so greatful.