Reputation: 31
I'm new to iOS and work on displaying mathematical terms in an appropriate notation on the iPad. I've learned that MathML is recently not supported by WebKit, so I'm trying to use SVG.
What I need is a simple example (or tutorial) of how to display a SVG-Element in an UIWebView by passing the complete content (created dynamically) as a NSString to the UIWebView - I don't want to make any use of files etc. and the App has to work completely offline.
P.S. Links to tutorials I've found, but they cover always loading e.g. pictures from a file etc.?
I appreciate any help (examples, links, etc.)
Upvotes: 3
Views: 1400
Reputation: 3303
maybe something like this
get NSData from NSString
NSData *svgData = [svgStr dataUsingEncoding:...];
then
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];
[baseURL release];
Upvotes: 4