WebView 无法加载 Google 图表 URL(NSUrl 保持为零)
我尝试在 UIWebView 中从 Google Chart 加载 URL。这是有趣的代码:
NSString *urlAddress = @"http://chart.apis.google.com/chart?chxr=0,5,398.333&chxs=0,676767,11.167,0.833,l,676767&chxt=x&chs=300x225&cht=lc&chco=3D79FF&chd=s:ilowy0zvvzrligikqsrl&chg=14.3,-1,0,0&chls=2&chm=B,C5D4EABB,0,0,0|R,FF0000,0,0,0.03|R,000000,0,0.3,0.33";
NSURL *url = [NSURL URLWithString:urlAddress];
if (url == nil) {
NSLog(@"URL error occured");
} else {
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[webView loadRequest:requestObj];
}
记录消息“发生 URL 错误”。
提前致谢!
I try to load an URL from Google Chart in a UIWebView. Here is the interesting code:
NSString *urlAddress = @"http://chart.apis.google.com/chart?chxr=0,5,398.333&chxs=0,676767,11.167,0.833,l,676767&chxt=x&chs=300x225&cht=lc&chco=3D79FF&chd=s:ilowy0zvvzrligikqsrl&chg=14.3,-1,0,0&chls=2&chm=B,C5D4EABB,0,0,0|R,FF0000,0,0,0.03|R,000000,0,0.3,0.33";
NSURL *url = [NSURL URLWithString:urlAddress];
if (url == nil) {
NSLog(@"URL error occured");
} else {
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[webView loadRequest:requestObj];
}
The message "URL error occured" is logged.
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
像这样使用。
Use like this.
我自己找到了解决方案:
NSUrl 对象不接受 URL 中的管道 (|)。必须将管道替换为 %7c 来逃脱管道
I've found the solution on my own:
The NSUrl object does not accept pipes (|) within an URL. One has to escape the pipes by replacing them with %7c