UIWebView:加载 URL 时出错
我正在尝试为 Tom's Hardware 网站构建一个 RSS 阅读器。
当我尝试从 RSS 链接将 URL 加载到 UIWebview 时出现错误。
这是我的代码:
- (void)viewDidLoad {
[super viewDidLoad];
if (self.url != nil) {
NSURL *requestUrl = [NSURL URLWithString:self.url];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:requestUrl];
[webView loadRequest:requestObj];
}
}
url 由父控制器设置。
当 URL 直接来自 RSS 时,我在日志中出现错误:
[2234:207] Error Domain=WebKitErrorDomain Code=101 UserInfo=0x3a6a240 “操作无法完成。(WebKitErrorDomain 错误 101。)”
当我手动设置URL 与下面的 URL 相同,它可以工作!
self.url = @"http://www.presence-pc.com/tests/fraude-financiere-paget-macafee-23198/#xtor=RSS-12";
以下是 URL 示例: http ://www.presence-pc.com/tests/fraude-financiere-paget-macafee-23198/#xtor=RSS-12。我不知道这个问题。
我希望你能帮助我。
此致。
I am trying to build an RSS reader for the Tom's Hardware website.
I have an error when I try to load an URL into an UIWebview from an RSS link.
Here'is my code:
- (void)viewDidLoad {
[super viewDidLoad];
if (self.url != nil) {
NSURL *requestUrl = [NSURL URLWithString:self.url];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:requestUrl];
[webView loadRequest:requestObj];
}
}
The url is setted by the parent controller.
When the URL comes directly from the RSS, I have an error in log:
[2234:207] Error Domain=WebKitErrorDomain Code=101 UserInfo=0x3a6a240 "Operation could not be completed. (WebKitErrorDomain error 101.)"
When I set manually the URL with the same URL like below, it work !
self.url = @"http://www.presence-pc.com/tests/fraude-financiere-paget-macafee-23198/#xtor=RSS-12";
Here is an URL exemple: http://www.presence-pc.com/tests/fraude-financiere-paget-macafee-23198/#xtor=RSS-12. I have no idea about that problem.
I hope you can help me.
Best regards.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
谢谢大家,就是这样,我已经像这样分割了 URL:
NSArray *split = [url elementsSeparatedByString:@"#"];
现在可以了,感谢您的帮助!
Thanks guy, that'it, I have split the URL like this:
NSArray *split = [url componentsSeparatedByString:@"#"];
and now it work , thanks for your help !
我有这个代码,它也会触发错误代码101
RedirectURL是一个
NSString
,其格式为http%3A%2F%2Fwww.linkedin.com%2Fnhome%2F我尝试使用 NSString 的方法删除百分比转义,现在它可以工作了。
I have this code which also triggers error code 101
RedirectURL is an
NSString
which has this format http%3A%2F%2Fwww.linkedin.com%2Fnhome%2FI tried removing percent escapes using the method of
NSString
and it now works.我认为问题可能出在你的网址中的锚点上,一位朋友也遇到了同样的问题
I think the problem can be the anchor in your URL, a friend got the same problem