iPhone Development - SVG image in UIWebView

2019-05-23 21:26发布

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条回答
Deceive 欺骗
2楼-- · 2019-05-23 22:12

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.

查看更多
登录 后发表回答