简体   繁体   中英

Link follows when using UIWebView+AFNetworking

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 .

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?

It might be worth reading through the implementation of UIWebView+AFNetworking (it's only 120 lines).

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.

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.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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