[英]Any workaround for iOS8 bug that affects HTML Select inside UIWebView (e.g. Cordova, PhoneGap)?
[英]ios8 UIWebview svg embaded html not show
我最近正在開發一個svg地圖應用程序。 在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
我注意到有一個動畫標簽的SVG顯示正常,而那些沒有顯示的SVG顯示。 將偽動畫標簽添加到svg是我暫時使用的解決方法。
...
<animate attributeName="opacity" values="0.99;1.0" dur="0.01s" begin="0s" repeatCount="1"></animate>
</svg>
更新:
此問題已在iOS 8.1.2(可能更早)中修復,因此不再需要此問題。
使用此解決方案如何強制WebKit重繪/重繪以傳播樣式更改? 為我解決了這個問題,沒有通過圖像修改HTML結構(我需要svg保持嵌入)。
所以我的最終代碼是這樣的:
var emb = document.querySelector( '.myCSSClass');
svgItem = emb.getSVGDocument.getElementsByTagName('svg')[0]
svgItem.style.display='none';
var somethinguseless = svgItem.offsetHeight; // SHOULD not need to store this anywhere, the reference is enough. Without a ref, the closure compiler removes it
svgItem.style.display='block';
僅供參考:我今天早上測試了iOS 8.1更新,修復了嵌入式標簽中的SVG ...
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.