简体   繁体   English

使用UIWebView + AFNetworking时出现链接

[英]Link follows when using UIWebView+AFNetworking

I'm trying out AFNetworking 2.0+'s new UIKit+AFNetworking extension for UIWebView , loadRequest:progress:success:failure: . 我正在尝试AFNetworking 2.0+的UIWebView的新UIKit+AFNetworking扩展, loadRequest:progress:success:failure: UIKit+AFNetworking So far so good, but after the initial request is made, additional requests caused by user interaction falls back to the built-in loadRequest: of plain UIWebView . 到目前为止,还不错,但是在发出初始请求之后,由用户交互引起的其他请求将退回到纯UIWebView的内置loadRequest:

I'd much prefer that all requests went through the AFNetworking improved one. 我非常希望所有请求都通过AFNetworking改进。 Preliminary, I'm thinking I should override as much as possible by returning NO in shouldStartLoadWithRequest and call loadRequest:progress:success:failure: manually, but it seems a little heavy-handed. 初步来说,我想我应该通过在shouldStartLoadWithRequest返回NOshouldStartLoadWithRequest调用loadRequest:progress:success:failure:来尽可能地重写,但这似乎有点笨拙。

Is this the intended way or am I missing something in the documentation? 这是预期的方式还是我在文档中缺少某些内容?

It might be worth reading through the implementation of UIWebView+AFNetworking (it's only 120 lines). 也许值得一读UIWebView + AFNetworking实现 (只有120行)。

What you're looking for isn't implemented by this class. 该类未实现您要查找的内容。 Furthermore, since UIWebView+AFNetworking is a category, which extends an existing object, implementing it in this class would require setting the UIWebView's delegate to itself, which would stop you from responding to any of its delegate methods. 此外,由于UIWebView+AFNetworking是扩展现有对象的类别,因此在此类中实现该对象将需要将UIWebView的委托设置为其自身,这将使您无法响应其任何委托方法。

Your discussed possible approach - returning NO to -[id<UIWebViewDelegate> webView:shouldStartLoadWithRequest:navigationType:] and then redirecting to use the method you want is the right approach. 您讨论过的可能方法-将NO返回到-[id<UIWebViewDelegate> webView:shouldStartLoadWithRequest:navigationType:] ,然后重定向以使用所需的方法是正确的方法。 (You'll need to return YES for your own request.) (您需要为自己的请求返回YES 。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM