views:

130

answers:

3

Hi,

my UIWebView is behaving strangely. For example, if I go from http://google.co.uk to http://ftd.de (a news site), it will start looping with errors. It doesn't care if I press stop or not, it just continues.

The log outputs the following and loops the message:

2010-09-03 16:16:55.061 Test [1336:207] http://www.ftd.de/
2010-09-03 16:16:55.077 Test [1336:207] {
    NSErrorFailingURLKey = http://www.ftd.de/;
    NSErrorFailingURLStringKey = "http://www.ftd.de/";
}
2010-09-03 16:16:55.082 Test [1336:207] http://www.google.co.uk/
2010-09-03 16:16:55.101 Test [1336:207] {
    NSErrorFailingURLKey = http://www.google.co.uk/;
    NSErrorFailingURLStringKey = "http://www.google.co.uk/";
}

and this keeps on looping until I kill the app.

What can cause something like this? The error dictionary, as you can see, doesn't provide any information on the error.

So I've attempted this workaround:

if ([[error userInfo] objectForKey:@"NSLocalizedDescription"] == nil)   {       NSLog(@"Stop!");        
[browser goBack];       
[browser stopLoading];  
}

However this doesn't stop the webview either.

Any ideas? :) I'm using the iPad SDK.

+1  A: 

I'm not sure I'm understanding the context of when stopLoading is getting invoked.

I also don't understand why you would call goBack before calling stopLoading... this is obviously just the context you are trying to work with it in... which I'd guess it the wrong context or a difficult context to try to work in....

So ... so yeah anyway, try forgetting all that context you are trying to work in now and just simply given the behavior you are describing try something else:

One Suggestion: Get rid of your workaround attempt and try this workaround instead- Before loading any request/Before invoking loadRequest anywhere... Why not just try calling stopLoading? So to reiterate just call stopLoading immediately before anywhere you are calling loadRequest.

It's worth a try. Like I said, I think your goBack and stopLoading invokes are misplaced and even still the context of them aren't really clear in the first place anyway... so end result is you should try some more work arounds because it's hard for me to help you refine your current workaround with the info you've provided.

Let me know if you need more suggestions for workarounds... just figured I'd provide them one at a time for now.

Pimp Juice McJones
Well this issue only happens on certain websites, but your idea is good. Ill try this.
David Schiefer
A: 

Have you checked the part where you are sending the commands to load these sites to see how often they are called? Maybe your code is accidently calling these repeatedly.

No one in particular
I have checked and they are called once. The error delegate is called several times every second though.
David Schiefer
A: 

The problem might be that you were passing "http://ftd.de" as a string to the webview not as a URL.

More clearly saying are you using something like:

[webview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://ftd.de"]]]; 

Hope this solves the probem.

Madhup
this is exactly how I load my websites though?
David Schiefer