我最近在开发一个 svg map 应用程序。 ios7 一切正常。当我将我的项目移动到 ios8 时。奇怪的事情发生了,我发现当 UIWebview 读取本地嵌入了 svg 文件的 html 文件时,svg 文件不会在 ios8 上显示。
示例代码在这里:
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
NSString *path = [[NSBundle mainBundle] pathForResource:@"test" ofType:@"html"];
NSURL *fileURL = [[NSURL alloc] initFileURLWithPath:path];
NSURLRequest *req = [NSURLRequest requestWithURL:fileURL];
[self.webView loadRequest:req];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
@end
和使用的html文件:
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title>SVG DEMO</title>
</head>
<body>
<div>
<embed src="410.svg" width="64" height="64" type="image/svg+xml" />
<object type="image/svg+xml" data="410.svg" width="64" height="64" border="1"></object>
</div>
</body>
</html>
有人知道这是怎么回事吗?
谢谢
最佳答案
我的申请遇到了同样的问题。 我找到了这个解决方案:
<!DOCTYPE html>
<html>
<head>
<title>Informations</title>
</head>
<body>
<center><img src="logo.svg" width="200" height="200" /></center>
</body>
</html>
适用于 iOS 7.0.3 和 8.0
关于html - ios8 Webview svg 嵌入 html 不显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25905041/