开发者

sending bool value from uiwebview to source code

I have 3 files, appdelegate.h, appdelegate.m, and mainwindow.xib

I have a uiwebview set up to load my site within those three files. I have a link in my site that triggers a JS function that changes the window location to /test/

Now, I want that link to trigger a function in the app, so I have this code:

- (BOOL)webView:(UIWebView *)webView
shouldStartLoadWithRequest:(NSURLRequest *)request
 navigationType:(UIWebViewNavigationType)navigationType {

    if ( [request.mainDocumentURL.relativePath
          isEqualToString:@"/test"] ) {
        NSLog( @"test" );
        return false;
    }


    return true;
}

it is cu开发者_高级运维rrently in the appdelegate.m file. Nothing happens when I change the location to /test. What to do?


Make sure that you set the delegate of the UIWebView to your app delegate

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜