I am developing an app for iphone/ipad that I have some problems with.
I am building dynamically a nsmutablestring with html code and loading as html to a uiwebview. I also load a local js file to this html page where I have some logical functions.
In this html I got a form with a submit button at the end.
What I am trying to do is that at the moment the submit button is click, it will call a method that return a string back to the objective-c code. I have no problem with the javascript controlling the form. But when the submit button is click, the native code gives me
Error Domain=WebKitErrorDomain Code=102 "Frame load interrupted" UserInfo=0x6c60b20 {NSErrorFailingURLKey=file://
I have tried to redirect in js-function like window.location=”myapp:custom:”+string; But I got the same problem. Even trying libraries like JSBridge api.
I suspect that is because I am loading a NSString to the webview that has the baseUrl the mainbundle path for loading the local js-file.
NSString *path = [[NSBundle mainBundle] bundlePath];
NSURL *baseURL = [NSURL fileURLWithPath:path];
[self.webView loadHTMLString:string baseURL:baseURL];
I only had to change the input submit with a input button in the html code and works. So now I got the string from javascript back to objective-c.