In my application, i’m using a Webview to load different versions of a website based on user’s preferred language.Using WebFrame’s loadRequest method for this –
[[aWebView mainFrame] loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:aStr]]];
If, aStr contains english alphabets only,i.e if aStr = http : // ……/language/English ,then its working fine & the webpage loads. But if aStr is something like http: //……/language/ウンウンウン(Japanese), nothing happens, neither WebView loads, nor it throws any error. If i paste the same link in Safari, the webpage loads there. Any suggestion on how to fix this issue?
I’ve also tried [aWebView setMainFrameURL:aStr] method. Same issue there too.
You have to escape the invalid URL characters in
aStrbefore you can use it to create the NSURL using[aStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding].URLWithString:returns a nil value if the string is invalid. Which is why you your UIWebView has no error and does not load anything.