将视口与 svg、uiwebview iphone 一起使用
它解释了如何使用视口来定义默认值缩放适用于 iOS 设备的网页。
我的问题是我想在我的 uiwebview 上显示 SVG 文件。我以这种方式加载我的 svg :
- (void)viewDidLoad {
// Loading the SVG file from resources folder
NSString *filePath = [[NSBundle mainBundle]
pathForResource:@"carteregionvin" ofType:@"svg"];
NSData *svgData = [NSData dataWithContentsOfFile:filePath];
NSString *resourcePath = [[NSBundle mainBundle] resourcePath];
NSURL *baseURL = [[NSURL alloc] initFileURLWithPath:resourcePath isDirectory:YES];
[self.webView loadData:svgData
MIMEType:@"image/svg+xml"
textEncodingName:@"UTF-8"
baseURL:baseURL];
我的 svg 已正确加载和显示,但是我如何使用/插入此:
<meta name = "viewport" content = "initial-scale = 1.0">
与 loadata 来定义比例?
如果不可能,objectiveC 有没有办法在单击 SVG 文件后重置缩放级别?因为我的scalePageToFit是true,所以在某些情况下我需要重置缩放。
抱歉我的英语不好,谢谢你的帮助
in this page : http://developer.apple.com/library/safari/#documentation/appleapplications/reference/safarihtmlref/Articles/MetaTags.html
it's explain how to use viewport to define default scale in a webpage for ios devices.
My probleme is that I want to display an SVG file on my uiwebview. I load my svg this way :
- (void)viewDidLoad {
// Loading the SVG file from resources folder
NSString *filePath = [[NSBundle mainBundle]
pathForResource:@"carteregionvin" ofType:@"svg"];
NSData *svgData = [NSData dataWithContentsOfFile:filePath];
NSString *resourcePath = [[NSBundle mainBundle] resourcePath];
NSURL *baseURL = [[NSURL alloc] initFileURLWithPath:resourcePath isDirectory:YES];
[self.webView loadData:svgData
MIMEType:@"image/svg+xml"
textEncodingName:@"UTF-8"
baseURL:baseURL];
My svg is correctly loaded and displayed, but how can i use/insert this :
<meta name = "viewport" content = "initial-scale = 1.0">
with a loadata to define the scale?
if it's not possible, is there a way with objectiveC to reset the zoom level after a click on the SVG file? Cause my scalePageToFit is true, so i need in some case to reset the zoom.
sorry for my english, thanks for your help
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你需要将其插入到 svg 的 xml 中吗?我会将 svg 文件作为可变字符串加载,并使用一些匹配找到它的正确位置,并将其插入到该位置。
如果您希望将其包含在文档标记中,您应该在 html/xhtml/xml 文件中引用 svg。
do you need that inserted into the svg's xml? I would load the svg file as a mutable string and use some matching find the proper location for it, and insert it at that location.
if you want that to be in document markup you should reference the svg in and html/xhtml/xml file.