Skip to content

Break on reload #3

@mbeckham

Description

@mbeckham

In using this library I have noticed that the functionality breaks when reloading a page or navigating to a new page.

_webView.delegate = self;

javaScriptInterface* interface = [javaScriptInterface new];

[self.webView addJavascriptInterfaces:interface WithName:@"interface"];

interface.webView = self;

[interface release];

[[NSURLCache sharedURLCache] removeAllCachedResponses];

 [_webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"mywebpage.com"]]];

This is the code I use for an initial load of the page. If I call another loadrequest on the same webview the communication between javascript and obj-c stops working. I am working with a web page that is designed to make a lot of calls to these interface functions, and without them the webpage is broken.

This also doesn't work if I try to add a new interface before reloading.

Is there any work around or fix to this? At the moment I am creating a new webview everytime I need to reload and destroying the old one, but would like to use one webview for everything.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions