Frage

I've start to learning UIWebView and I have next problem. When I'm trying to use next code:

 NSString *searchString = [NSString stringWithFormat:@"http://www.google.com/search?q=%@",lookedCity];
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:searchString]]];

or:

NSString *searchString = [NSString stringWithFormat:@"http://en.wikipedia.org/wiki/%@",lookedCity];
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:searchString]]];

my WebView doesn't loading page. But if I use standart URLs (ex. google.com), all works fine. In case with Wiki, I tried use WikiApiObjectiveC, but even example doesn't work. How can I solve this problem? The best solution will be with Wiki URL.

War es hilfreich?

Lösung

Problem solved! The reason, why my URL doesn't work, was in cyrillic symbols in my searchString. Solution: urlString = [urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top