I would like to implement a function like adding a note of a selected text on UIWebview
as iBooks and Amazon Kindle does.
I already created UIMenuItem
. But, I dont know how to implement the method for this. Could anybody help in this regard?
I dont know what functionality is used to implement in this method. Thanks.
- (void)Note:(id)sender {
NSString *selection = [webView stringByEvaluatingJavaScriptFromString:@"window.getSelection().toString()"];
}
The JavaScript in question is designed to give you the text that is highlighted within your selection.
I'm not sure that running toString on an element will return the correct information though. The following method will return the highlighted text and save it into a variable.
when you have this method loaded into the webview