iPhone开发-UIWebView中的SVG图像 [英] iPhone Development - SVG image in UIWebView

查看:71
本文介绍了iPhone开发-UIWebView中的SVG图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用UIWebView在我的应用程序中显示带有相关javascript的svg图. .svg文件存储在本地.我面临的问题是放大/缩小和滚动太可怕了.大图像会发生这种情况.我已经在模拟器中对此进行了测试.有人知道原因吗?

I'm trying to display an svg graph with associated javascript in my application using UIWebView. The .svg file is stored locally. The problem i'm facing is that the zoom in/out and scrolling is horrible. This happens with large images. I've tested this in simulator. Does anyone know the reason?

我已经使用iPhone的Safari应用程序测试了很多svg图形,它们可以完美呈现,并且放大/缩小以及滚动效果完美(无抖动)-即使对于4-5 MB的图形也是如此.

I've tested quite a few svg graphs using iPhone's Safari App and they render perfectly, and zoom in/out plus scrolling works perfectly (without any jitters) - even for 4-5 MB graphs.

代码非常基础:

NSString *path = [[NSBundle mainBundle] pathForResource:@"image" ofType:@"svg"];
NSURL *fileURL = [[NSURL alloc] initFileURLWithPath:path];
NSURLRequest *req = [NSURLRequest requestWithURL:fileURL];
[webView setScalesPageToFit:YES];
[webView loadRequest:req];

我在这里做错什么了吗,还是我没有做我应该做的事情?

Am i doing something wrong here, or am i not doing something that i should?

注意:我尚未在 设备.

Note: I haven't tested this on the device.

感谢您的期待, 穆斯塔法(Mustafa)

Thanking in anticipation, Mustafa

推荐答案

您绝对应该在设备上对其进行测试.如果svg文件在设备的Safari应用程序中可以正常工作,则这可能只是模拟器存在的问题.

You should definitely test it on the device. If svg files work fine in the device's Safari app, then this may simply be an issue with the simulator.

这篇关于iPhone开发-UIWebView中的SVG图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆