i want to Select text using gesture and highlite that text.i had done display html page in UIwebview but uiwebview does not fire touch begin event, So how can开发者_Go百科 i do.
1) when user select text (i.e user select text "i Know uesr" that part of text color should be change.
if you have any idea below of the query,kindly suggest me..
Thank you
Milan
If you look at the docs for a UIWebView, you know your options are limited.
You're going to have do it with javascript. Your only weapon is - (NSString *)stringByEvaluatingJavaScriptFromString:(NSString *)script
and your ability to load every page as a string (which you can manipulate) before passing it to you UIWebView as a page (using - (void)loadHTMLString:(NSString *)string baseURL:(NSURL *)baseURL
).
So... good luck with that. ;)
Brute force method
You can trap the touches as the Window level by subclassing UIWindow. Then you can manually locate the view the touch occurred in and then the location in the view.
As to actually highlighting the text with the OS, I think you might have to put a transparent overlay view on top of the webview and then draw the highlight there.
You're going to have trouble selecting in a webview because a single touch also opens links. You're going to have to create an interface that distinguishes between link touches and selection touches.
精彩评论