I've included the Raphael JavaScript library into an iPhone project, however I'm not able to get it to work in a webview. I have a basic test where I should get a red circle. It works on Safari on the Mac but I can't get it to work on the iPhone simulator. I only get the "Hello This is a Raphael Test" text.
When I "Show Package Contents" on the app file in the Debug-iphonesimulator it shows that the JavaScript files are included.
I'm obviously not doing something right. Any ideas?
Below is the viewDidLoad content.
- (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];
}
Below is 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>