2014-09-18 7 views
5

मैं हाल ही में एक svg map ऐप पर काम कर रहा हूं। आईओएस 7 पर सब ठीक चल रहा है। जब मैं अपनी परियोजना को ios8 पर ले जाता हूं। अजीब चीजें हुईं, मैंने पाया कि UIWebview स्थानीय HTML फ़ाइल को पढ़ता है जिसमें एक svg फ़ाइल एम्बेडेड है, svg फ़ाइल ios8 पर नहीं दिखाई देगी।ios8 UIWebview svg embaded html दिखाया नहीं गया

नमूना कोड यहाँ है:

@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> 

किसी को भी पता है क्या हो रहा है?

धन्यवाद

उत्तर

5

मुझे अपने आवेदन के साथ एक ही समस्या थी। और मैं इस समाधान पाया:

आईओएस 7.0.3 के साथ
<!DOCTYPE html> 
<html> 
    <head> 
     <title>Informations</title> 
    </head> 
    <body> 
     <center><img src="logo.svg" width="200" height="200" /></center> 
    </body> 
</html> 

काम करता है और 8.0

+1

परीक्षण किया है आईओएस 8.1 अद्यतन हालांकि यह स्थिर एसवीजी के लिए काम करता है, यह मदद नहीं करता है जब एसवीजी स्क्रिप्ट में शामिल है। – walker

0

इस समाधान How can I force WebKit to redraw/repaint to propagate style changes? यह मेरे लिए हल का उपयोग करना, एक छवि के माध्यम से HTML संरचना को संशोधित किए बिना (मैं svg जरूरत रहने के लिए embeded)।

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'; 
+0

मुझे एहसास है कि यह एक जावास्क्रिप्ट उन्मुख समाधान है जो संदर्भ है जिसमें मुझे समस्या है (वेब ​​ऐप) – Moustachiste

3

मैंने देखा है कि SVGs है कि एक चेतन टैग किया था, ठीक दिखाया जबकि बिना उन दिखाई नहीं था:

तो मेरा अंतिम कोड की तरह के बारे में कुछ है। एसवीजी में एक डमी एनिमेट टैग जोड़ना वह समय है जिसका मैं उपयोग कर रहा हूं।

... 
<animate attributeName="opacity" values="0.99;1.0" dur="0.01s" begin="0s" repeatCount="1"></animate> 
</svg> 

अद्यतन:

यह समस्या आईओएस 8.1.2 (संभवतः पहले) में तय हो गई है, तो यह नहीं रह गया है की जरूरत है।

0

बस FYI करें: मैं आज सुबह एम्बेड टैग में एक SVGs तय कर रहे हैं ...

संबंधित मुद्दे