Domanda

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.

È stato utile?

Soluzione

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

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top