iPhone Development - SVG image in UIWebView

时光总嘲笑我的痴心妄想 提交于 2019-12-22 17:58:47

问题


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?

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.

The code is very basic:

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.

Thanking in anticipation, Mustafa


回答1:


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.



来源:https://stackoverflow.com/questions/1326709/iphone-development-svg-image-in-uiwebview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!