开发者

UIWebView not displaying images in SVG

I have local HTML files that I'm displaying with a UIWebView. Everything is displaying fine, except images embedded in a svg-tags, like such:

<body>
    <div>
        <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="100%" height="100%" viewBox="0 0 274 500" preserveAspectRatio="none">
            <image width="274" height="500" xlink:href="cover.jpeg"/>
        </svg>
    </div>
</body>

Normal <img> tags work fine, so there's nothing wrong with the baseURL, and the image is in the same folder. The HTML file loads fine in Mobile Safari. I've tried loading with -loadRequest:, and -loadString:baseURL: and -loadData:MIMEType:textEncodingName:baseURL, but I always just get a border corresponding to the width and height of the image, wi开发者_C百科thout the actual image.

What could be wrong?


Finally solved the issue. The DOCTYPE was set to strict XHTML:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">

but the file extension was html.

Changing the file extension to .xhtml solved the problem.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜