I've been trying to integrate the Raphael JavaScript library into my iPhone project, but I'm running into an issue with getting it to work in a webview. On Safari for Mac, everything seems fine and I can see the red circle as expected. However, when I try to view it on the iPhone simulator, all I get is the "Hello This is a Raphael Test" text.
Upon checking the app file in Debug-iphonesimulator, I can confirm that the JavaScript files are included there.
It's clear that I must be missing something crucial here. Any suggestions or ideas would be greatly appreciated.
Here is the content of the viewDidLoad:
- (void)viewDidLoad {
[super viewDidLoad];
NSString *htmlPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"TestRaphael.html"];
NSString *htmlContent = [NSString stringWithContentsOfFile:htmlPath encoding:NSUTF8StringEncoding error:nil];
[myWebView loadHTMLString:htmlContent baseURL:nil];
}
And here is the content of the TestRaphael.html file:
<html><head>
<title>Raphael Test</title>
<script src="raphael.js" mce_src="raphael.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>
<H1>Hello</H1>
<P>This is a Raphael Test</P>
<script language="javascript" type="text/javascript">
var paper = Raphael(10, 50, 320, 200);
var circle = paper.circle(50, 40, 10);
circle.attr("fill", "#f00");
circle.attr("stroke", "#fff");
</script></body></html>