Search code examples
iphoneobjective-cuipopover

Displaying a popover on a text tap


I'm working to try and create a kind of wiki-esque app, in that when you click on a piece of text displayed in a UITextView, the app displays a popover with the word's definition. I've been searching around and the best idea I have is just tracking the location on the screen of all of the text that can have a popover and then tracking where exactly finger taps occur and displaying a popover when they coincide. Are there any better solutions to this?

Thanks, Pete


Solution

  • The easiest way that I've figured out to do this is to go line by line and essentially paste a UIButton with the same text as the link over the original text. This means that I had to use UILabels for every line and then add them to an entire view. You get the same effect as a UITextView, but you can pinpoint the CGPoint where the text appears in a line.

    Kind of hacky, but it was the best solution I could find!