Tre*_*zar 2 javascript objective-c uiwebview ios
我有一个加载了一个简单的 rtf 文件的 UIWebView。(包含一行“这是一个测试”)
UIWebView* webview = [[UIWebView alloc] initWithFrame:CGRectMake(5, 50, 310, 400)];
[[self view] addSubview:webview];
[webview loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"test" ofType:@"rtf"]isDirectory:NO]]];
NSString *html = [webview stringByEvaluatingJavaScriptFromString: @"all"];
NSLog (@"html:%@", html.debugDescription);
Run Code Online (Sandbox Code Playgroud)
“THIS IS A TEXT”行正确显示在 UIWebView 中。有谁知道是否可以将那行文本(或更多)提取到 NSString 或其他一些可访问的容器中?
我知道有:
NSString *html = [webview stringByEvaluatingJavaScriptFromString: @"document.documentElement.outerHTML"];
Run Code Online (Sandbox Code Playgroud)
但这(显然)在这里不起作用。有任何想法吗 ?我基本上是在尝试(假)将 rtf 文件转换为 iOS 上的 NSString。谢谢!