UIWebView 不加载某些链接
你好 我正在尝试为我的 iPhone 编写一个 RSS feed 查看器。在我的 DetailView 中,我有一个 UIWebView,我想在其中显示使用 rss 项目检索到的特定链接。:
NSString* url = [data objectForKey:@"link"];
NSString *encodedUrl = [url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding ];
NSLog(@"Selected link:%@",url);
NSURLRequest *request = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:encodedUrl]];
[itemWebpage loadRequest:request];
[request release];
现在,如果检索到的链接是这样的,
www.shazaam.com
它就可以工作。但一旦链接出现类似:
http://www.shazam.com/music/web/track?id=41970148"
它没有。我想这是因为参数......但我该如何解决这个问题???
多谢!
埃洛斯
hello
I'm trying to write an rss feed viewer for my iPhone. In my DetailView I have a UIWebView where I want to display specific link retrieved with the rss item.:
NSString* url = [data objectForKey:@"link"];
NSString *encodedUrl = [url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding ];
NSLog(@"Selected link:%@",url);
NSURLRequest *request = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:encodedUrl]];
[itemWebpage loadRequest:request];
[request release];
now,if the retrieved link is something like
www.shazaam.com
it works. But as soon as the link is something like:
http://www.shazam.com/music/web/track?id=41970148"
it doesn't. I suppose it's because of the parameter...but how can I fix the problem????
thanks a lot!
elos
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
stringByAddingPercentEscapesUsingEncoding:
适用于要将字符串放入查询变量时。您不需要对整个 URL 执行此操作。问号在不应该被编码的时候被编码了,所以你会得到一个 404。不要对 URL 进行编码,你应该没问题。stringByAddingPercentEscapesUsingEncoding:
is for when you want to put a string into a query variable. You don't need to do it for entire URLs. The question mark is being encoded when it shouldn't be, so you are getting a 404. Don't encode the URL and you should be fine.