使用UIWebView + AFNetworking时会出现链接 [英] Link follows when using UIWebView+AFNetworking
问题描述
我正在为 UIWebView
,<$ c尝试AFNetworking 2.0 +的新 UIKit + AFNetworking
扩展程序$ C>的loadRequest:进展:成功:失败:。到目前为止一切顺利,但在初始请求完成后,由用户交互引起的其他请求将回退到内置的 loadRequest:
of plain UIWebView
。
I'm trying out AFNetworking 2.0+'s new UIKit+AFNetworking
extension for UIWebView
, loadRequest:progress:success:failure:
. 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
.
我更希望所有请求都通过 AFNetworking
改进一个。初步,我想我应该通过在 shouldStartLoadWithRequest
中返回 NO
来尽可能地覆盖并调用 loadRequest:进度:成功:失败:
手动,但似乎有点笨拙。
I'd much prefer that all requests went through the AFNetworking
improved one. 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.
这是预期的方式还是上午的我在文档中遗漏了什么?
Is this the intended way or am I missing something in the documentation?
推荐答案
可能值得一读 UIWebView + AFNetworking的实现(它只有120行)。
It might be worth reading through the implementation of UIWebView+AFNetworking (it's only 120 lines).
这个课程没有实现你想要的东西。此外,由于 UIWebView + AFNetworking
是一个扩展现有对象的类别,在此类中实现它需要将UIWebView的委托设置为自身,这将阻止您响应任何委托方法。
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.
您讨论的可能方法 - 将否
返回 - [ ID< UIWebViewDelegate> webView:shouldStartLoadWithRequest:navigationType:]
然后重定向以使用您想要的方法是正确的方法。 (您需要为自己的请求返回 YES
。)
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. (You'll need to return YES
for your own request.)
这篇关于使用UIWebView + AFNetworking时会出现链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!