【发布时间】:2011-08-08 03:34:03
【问题描述】:
我正在尝试在 Html 5 文件中使用 SVG 绘制一个基本圆圈,然后将其加载到 UIWebview 中。但是,当我编译并运行时,屏幕上什么也没有出现(在 iPad 上测试)。
我没有使用正确的代码还是 UIWebview 不支持带有 Html 5 的 SVG?
这是 UIWebview 的代码:
- (void)viewDidLoad
{
[super viewDidLoad];
NSString* path = [[NSBundle mainBundle] pathForResource:@"SVG" ofType:@"html"];
NSString* content = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
webView = [UIWebView new];
webView.frame = CGRectMake(0, 0, 1024, 768);
webView.dataDetectorTypes = UIDataDetectorTypeAll;
webView.userInteractionEnabled = YES;
[webView loadHTMLString:content baseURL:[[NSBundle mainBundle] bundleURL]];
[self.view addSubview:webView];
[webView release];
}
这是在资源文件夹中调用的 SVG.html 文件中的代码:
<!DOCTYPE html>
<head>
<title>SVG</title>
<meta charset="utf-8" />
</head>
<body>
<svg id="svgelem" height="200" xmlns="http://www.w3.org/2000/svg">
<circle id="redcircle" cx="50" cy="50" r="50" fill="red" />
</svg>
</body>
</html>
我已经阅读了许多相关的帖子,但我无法找到答案。
感谢任何帮助。谢谢。
【问题讨论】:
标签: iphone ios html uiwebview svg