0

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>
Anthony
  • 1
  • 1

1 Answers1

0

This seems to do with how xCode perceives the .js-file you added.

Did you get a warning like:

warning: no rule to process file '$(PROJECT_DIR)/raphael.js' of type sourcecode.javascript for architecture i386

Then read more about it over here

Community
  • 1
  • 1