无法在iOS中使用loadHTMLString:baseURL在UIWebView中加载html字符串?

Bha*_*ath 6 html iphone uiwebview ios

我正在尝试将youtube视频嵌入到我的iOS应用程序中.为此我创建了一个UIWebView &尝试Youtube此处加载视频

我已经完成了上述问题的所有答案.即使这样它也不起作用.我也试过加载非常简单的HTML

 NSString *embedHTML =[NSString stringWithFormat:@"<html><body>Hello World</body></html>"];
 [webView loadHTMLString:embedHTML baseURL:nil];
Run Code Online (Sandbox Code Playgroud)

即使这样,我也遇到了编译错误 Parse Issue Expecte ']'

我试过清理,退出XCode并重新启动它.我不知道,我无法使用那种方法.如何使用上面的loadHTMLString方法为我的UIWebView.

PS:请不要将此问题标记为重复.我已经尝试了所有的解决方案Stackoverflow.没有任何效果

msk*_*mar 5

WebView *webDesc = [[UIWebView alloc]initWithFrame:CGRectMake(12, 50, 276, 228)];

NSString *embedHTML = @"<html><head></head><body><p>1. You agree that you will be the technician servicing this work order?.<br>2. You are comfortable with the scope of work on this work order?.<br>3. You understand that if you go to site and fail to do quality repair for  any reason, you will not be paid?.<br>4. You must dress business casual when going on the work order.</p></body></html>";

webDesc.userInteractionEnabled = NO;
webDesc.opaque = NO;
webDesc.backgroundColor = [UIColor clearColor];
[webDesc loadHTMLString: embedHTML baseURL: nil];
Run Code Online (Sandbox Code Playgroud)


Mik*_*ike 0

如果您希望人们帮助您,您可能需要提供更多代码。我只是以类似的方式使用 webView 并且它工作正常。

self.webView = [[UIWebView alloc] initWithFrame:myFrame];
self.webView.scalesPageToFit = YES;
[self.webView setBackgroundColor:[UIColor whiteColor]];

//pass the string to the webview
[self.webView loadHTMLString:[[self.itineraryArray objectAtIndex:indexPath.row] valueForKey:@"body"] baseURL:nil];

//add it to the subview
[self.view addSubview:self.webView];
Run Code Online (Sandbox Code Playgroud)

您能提供更多信息和代码吗?