Ios 如何使用Swift从WebView获取所选单词?
我正在以这种方式加载本地pdf文件Ios 如何使用Swift从WebView获取所选单词?,ios,swift,webview,Ios,Swift,Webview,我正在以这种方式加载本地pdf文件 let myProjectBundle: NSBundle = NSBundle.mainBundle() let filePath: String = myProjectBundle.pathForResource("test2", ofType: "pdf")! let myURL = NSURL(string: filePath) let myURLRequest: NSURLRequest = NSURLRequest(URL: myURL!) sel
let myProjectBundle: NSBundle = NSBundle.mainBundle()
let filePath: String = myProjectBundle.pathForResource("test2", ofType: "pdf")!
let myURL = NSURL(string: filePath)
let myURLRequest: NSURLRequest = NSURLRequest(URL: myURL!)
self.webView.loadRequest(myURLRequest)
如何获取所选单词?这个函数每次都返回空字符串
webView.stringByEvaluatingJavaScriptFromString("window.getSelection().toString();")
不适用于pdf文件
非常感谢 你好。。!!你知道吗?我也在尝试同样的方法。该函数仅适用于HTML。不是PDF格式。如果你知道怎么做,请指导我。请。。