Displaying a popover on a text tap - iphone

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

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!

Related

Is there a way to capture/scrape the text content programmatically on iOS?

Similar to taking a screenshot programmatically, except, I want just the text contents on the screen. I guess I could put the screenshot through an OCR, but, I am hoping there's a better solution.
one way of doing it take the UIWindow instance and traverse through all the views in the window and check whether they are subclass of UILabel and UITextField or UITextView, if they are you can take the text from there.

Focus and zoom in on a UITextField when touched?

How in the world does one get the iPhone view to zoom in on a focused UITextField? I need to tap on a text field that I want to edit, and my view should zoom in to the tapped text field and pull up the keyboard (which it already does), similar to how many Internet text fields gain focus on the iPhone. Is this some type of overlay?
I've been looking everywhere for this solution but maybe I've just got the wrong terminology. Thank you in advance.
Could be a duplicate of this StackOverflow question.
In essence, there are a number of ways, but you have to program this effect manually. A textfield is already an overlay. You can either move it, or scroll the containing view.
Please follow the following steps.
Implement the delegate method for all textfield.connect the outlet of textfield in interface builder basically it's setting the delegate property.then in delegate property you can defined the method whatever you want to implement or wanted to do functionality.
Thanks

Drag and drop a highlighted text within an iphone TextView

I'm trying to highlight a word then drag and drop it anywhere within the iphone UITextView. Can anyone help? Thank you much!
Ok, you're going to run into two problems.
problem 1) you need to add a gesture for a drag and drop. Defining a new gesture that will select the a word and drag it should be too hard.
http://developer.apple.com/library/ios/documentation/EventHandling/Conceptual/EventHandlingiPhoneOS/GestureRecognizers/GestureRecognizers.html#//apple_ref/doc/uid/TP40009541-CH6-SW13
this portion of the article should lead you in the right direction.
problem 2) You can't just add the gesture to the UITextView when you load. When you select a UITextView it will become the first responder by default. When the keyboard is loaded the UITextView class will add Gestures to the TextView to handle the standard text edit gestures. After this the UITextViewTextDidBeginEditingNotification will get sent
you should then add your gesture to the textview at this point. Otherwise it will get over written.
I hope this leads you in the right direction. Good luck.

UITextView Paging Enabled Text cut off

I am using a UITextView and enabling paging (in both IB and programatically toggling it on and off). There's a lot of text and when scrolling with paging enabled sometimes the first and/or last line of the currently viewable text ends up halfway in view and half out of view at the bottom or top of the frame so you can only see the top or bottom half of that line of text.   (I hope I'm explaining that correctly)
Does anyone know a way to insure that it pages correctly so it there's no lines of text half cut off?? 
A few notes
1. The font size is adjustable by the user.
2. I've tried setContentOffset,setContentInset,setContentSize and it's not helping (unless I'm using them wrong)
3. I am using a txt file to populate the UITextView
Thanks in advance!!
UITextView is a subclass of UIScrollView. As such I do not believe UITextView actually supports paging as this is a feature of UIScrollView. Can you please take a step back and explain the end goal, as it sounds like rendering an NSString in to a UIScrollView might be actually what you want, instead of a UITextView.

adding a textbox and a button at the top of the keyboard on iphone

I want to add a text box and a button beside it. They will be at the bottom of the window. Then, when I touch the textbox (to type something), keyboard will appear and the whole row (with textbox and button) scrolls up and the keyboard will be right below them. Could you please let me know how can I do that?
Is there any sample program?
Thanks.
Matt Gallagher posted this on his blog:
Sliding UITextFields around to avoid the keyboard
It is a step by step example of exactly what you want.
In the XCode documentation iPhone Application Programming Guide there is a section on "Moving Content That Is Located Under the Keyboard" that talks about receiving keyboard notifications when a keyboard is about to show. There's code there to show you how to get the keyboard size (which varies depending on the orientation). I won't repeat it here.
You can use the same technique to get the UIKeyboardWillShowNotification notification and get the height of where the keyboard will end up. That gives you the bottom edge of where your view needs to go, effectively putting it above the keyboard. So just put your textbox and button inside a view. When you get the notification tell your view where it needs to go (keyboard height + height of the container view) and you're done. You'll also want to catch UIKeyboardWillHideNotification to move the view back to where it was, so keep track of the original container view position.
It's pretty straightforward and it'll look nice, especially if you use a nice UIView animation effect and set the timing just right.