I have an application in which I download an html file from the server and show it in uiwebview,
NSArray *paths = NSSearchPathForDirectoriesInDomains( NSDocumentDirectory, NSUserDomainMask ,YES );
NSString *documentsDirectory = [paths firstObject];
NSString *path = [documentsDirectory stringByAppendingPathComponent:[dictionary valueForKey:@"htmlfilename"]];
NSError *err;
NSString *html = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:&err];
[self.webview loadHTMLString:html baseURL:[NSURL fileURLWithPath:path]];
Like this, after that in DidfinishloadI upload one JS file which is added to my application package like this
NSString *javaScript=[NSString stringWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"foo" ofType:@"js"] encoding:NSUTF8StringEncoding error:nil];
[webview stringByEvaluatingJavaScriptFromString:javaScript];
After that, when I press the button, I call stringByEvaluatingJavaScriptFromString, but it does not work. Even the javascript file itself does not load. Can anyone direct me to this?
source
share