tags:

views:

375

answers:

3

Hi All, What I am trying to do is create tooltip functionality so that certain words in my instructional app can be tapped and the definition pops up. For the popup part I plan on using code from “AFInformationView” which provides bubbles on the iPhone.

The part I'm struggling with is how to associate A particular word's location with the bubble. Currently I have the text on a UILabel that is on a custom UITableCell. Since I calculate the row height on the fly with:

[textToUse  sizeWithFont:[UIFont systemFontOfSize:FONT_SIZE] constrainedToSize:CGSizeMake(stop-start, 500)];

I'm not sure what the coordinates for a specific word will be. I was thinking that if I created a custom DataDetectorType that could be the fix.

If anyone knows how to do this or has any other ideas I would be happy to hear them.

Thanks,

Andrew

A: 

I don't think this is possible. The (few) Data Detector types that the iPhone currently supports are hard-coded with a integer type id. There does not seem to be a mechanism to extends that list of types.

File a feature request in their bug tracker. I will do the same.

St3fan
A: 

AFAIK, you can't create custom data detectors.

The best approach for this sort of thing seems to be using UIWebViews. At least that's what I did. However, you shouldn't use a UIWebView inside a UITableViewCell. In fact, no subview of a UITableViewCell should respond to user input. So I think the best approach would be to display a UIWebView when the cell is tapped.

Can Berk Güder
"So I think the best approach would be to display a UIWebView when the cell is tapped."Could you describe that approach a little more?
KingAndrew
Assuming your table view is inside a navigation controller, push a UIWebView that displays the table cell's contents using custom, device-generated HTML.
Can Berk Güder
A good example would be Tweetie 2. When you tap on a tweet in the timeline, a UIWebView that displays the contents of the tweet is pushed. @references and links are interactive in the tweet view, but not in the timeline view.
Can Berk Güder
"In fact, no subview of a UITableViewCell should respond to user input." I'm going to disagree with this statement. Apple places buttons on the right and left side of TabelCells depending on the situation. So I think that user interaction with a cell is permissible.
KingAndrew
@KingAndrew: You're right. Editing mode and detail disclosure buttons are two big exceptions to this rule. Also, this is not in the HIG but, Apple is known for ignoring the HIG occasionally.
Can Berk Güder
A: 

I didn't create a custom UIDataDetectorTypes but Craig Hockenberry did something like it with his TwitterrificTouch.

He uses regular expressions to detect links and other things. I provide it with my keywords and then they become tappable. He places buttons on top of the matching text from the underlying labels. You can google a lot of posts that talk about "putting transparent buttons on top" of various things but Craig's code is the only example/working code I could find.

Here is the link: http://furbo.org/2008/10/07/fancy-uilabels/

KingAndrew