开发者

Tapping on a word in a UITextView

I want to allow users to type some text in my iPhone app, 开发者_开发问答and when they tap/touch a word or sentence, then call a method on that word.

My problem is how do I do it?

I got the idea from from the app AudioNote: http://luminantsoftware.com/iphone/audionote.html

Does anyone know how to go about it?!


It looks like they may be using a UIWebView to display the text. This gives you the advantage of being able to apply different formatting to individual words.

To handle tapping on words you could create them as hyperlinks and detect the touches using:

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType

**oops, sorry forgot about entering the text. Don't know how to do that with a webview.


What do you mean by "call a method on that word"?

Where I would start looking would be in the UITextView documentation and the UITextViewDelegate documentation

If I understand what you want to do, you might be able to do it with the UITextViewDelegate method

- (void)textViewDidChangeSelection:(UITextView *)textView
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜