I am recently working on a svg map app. everything is running fine on ios7. when i move my project to ios8. strange things happened, I found when UIWebview read local html file which has a svg file embedded, the svg file will not shown on ios8.
sample code is here:
@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
and the html file used:
<!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>
Does anyone know what's going on?
Thanks
I had the same problem with my application. And I found this solution:
<!DOCTYPE html>
<html>
<head>
<title>Informations</title>
</head>
<body>
<center><img src="logo.svg" width="200" height="200" /></center>
</body>
</html>
Works with iOS 7.0.3 and 8.0
I noticed that SVGs that had an animate tag showed up fine, while those without did not show up. Adding a dummy animate tag to the svg is the workaround I'm using for the time being.
...
<animate attributeName="opacity" values="0.99;1.0" dur="0.01s" begin="0s" repeatCount="1"></animate>
</svg>
Update:
This issue is fixed in iOS 8.1.2 (possibly earlier), so this is no longer needed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With