• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How to get tapped text from UITextView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to get tapped text from UITextView


  • Subject: Re: How to get tapped text from UITextView
  • From: Alex Kac <email@hidden>
  • Date: Sat, 1 May 2010 11:46:27 -0500

It would be simpler to save the CGRect you calculate per word in an array and just enumerate the rects for the point tapped.

--
Alex Kac
On my mobile device so please excuse the brevity.

On May 1, 2010, at 12:19 AM, Sasikumar JP <email@hidden> wrote:

> Alex,
> 	I can draw the text using NSString's drawing method. But I am not clear how to get the tapped String using touch point or GCRect. I don't any direct method to get the String by passing CGPoint or CGRect.
>
>
> I was able to successfully implement this feature by creating CATextLayer for each word and put all the layers as a sublayer of UIView's layer object. When user tapped on this View, hitTest method would return the Layer which was tapped.  Using the Layer Object i was able to get the tapped string.
>
> Does this approach cause any performance or memory related issue. since i am creating CATextLayer object for each word.
>
> Thanks
> Sasikumar
>
> On 30-Apr-2010, at 8:44 PM, Alex Kac wrote:
>
>> You are going to have to draw the text yourself using NSString's drawing methods and then use the regular touch events and CGRects to do that. Or use a UIWebView with links to each word that you recognize.
>>
>> --
>> Alex Kac
>> On my mobile device so please excuse the brevity.
>>
>> On Apr 30, 2010, at 12:38 AM, Sasikumar JP <email@hidden> wrote:
>>
>>> Hi,
>>> 	I am working on a iPhone Application. I want to implement the following feature in my app, but i don't know how to implement it.
>>>
>>> 	I want to display the read-only text content in UITextView, where user can tap any word in the text. It should take the user to next screen to display more detail about the tapped word.
>>>
>>> 	I dont know how to get tapped word from the UITextView.
>>>
>>> 	I have set the UITextView as a read-only to avoid the popping key-board and I have subclassed the UITextView to override the canPerformAction: withSender to disable the cut & paste feature.
>>>
>>> 	I have overridden touchesBegan method to get the touch/tap Event. But i am not sure how to get only the tapped word from the complete text.
>>>
>>>
>>> 	Any help is highly appreciated.
>>>
>>>
>>> Thanks
>>> Sasikumar_______________________________________________
>>>
>>> Cocoa-dev mailing list (email@hidden)
>>>
>>> Please do not post admin requests or moderator comments to the list.
>>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>>>
>>> Help/Unsubscribe/Update your Subscription:
>>>
>>> This email sent to email@hidden
>
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: Re: Re-establishing KVO in Managed objects after undo
  • Next by Date: Re: Re-establishing KVO in Managed objects after undo
  • Previous by thread: Re: the case of the missing scroll bar
  • Next by thread: Re: Matching the style of a HUD?
  • Index(es):
    • Date
    • Thread