【发布时间】:2014-04-09 05:45:02
【问题描述】:
我创建了一个 html,我想将它加载到我的 webview 并传递参数,即宽度、高度和视频 ID。
<html>
<body>
<script type='text/javascript' src="http://www.example.com/api"></script>
<iframe id='player' type='text/html' width='%d' height='%d' src="http://www.youtube.com/embed/%@?enablejsapi=1&rel=0&playsinline=1" frameborder='0'>
<script type='text/javascript'>
..... my code/functions here
</script>
</body>
</html>
现在,我在代码中写的是 -
NSString* html = nil;
NSString *htmlContent = [[NSString alloc] initWithContentsOfURL:[NSURL fileURLWithPath:youTubeHTMLFilePath] encoding:NSUTF8StringEncoding error:&error];
html = [NSString stringWithFormat:htmlContent, 320, 208, videoId];
[self.myWebview loadHTMLString:html baseURL:nil];
但它无法加载这个 html 字符串。
如果有人能帮我弄清楚,请。 提前致谢。
【问题讨论】:
标签: ios iframe youtube-api