如何在UIwebview上添加注释
我想实现一个功能,例如像 iBooks 和 Amazon Kindle 那样在 UIWebview
上添加所选文本的注释。
我已经创建了 UIMenuItem
。但是,我不知道如何实现这个方法。有人可以在这方面提供帮助吗?
我不知道这个方法是用来实现什么功能的。谢谢。
- (void)Note:(id)sender {
NSString *selection = [webView stringByEvaluatingJavaScriptFromString:@"window.getSelection().toString()"];
}
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()"];
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
相关 JavaScript 旨在为您提供在您的选择中突出显示的文本。
但我不确定在元素上运行 toString 会返回正确的信息。以下方法将返回突出显示的文本并将其保存到变量中。
当你将此方法加载到 webview 中时
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