我认为用 UIWebView (和委托=自我)对每个 viewController 实现完全相同的方法并不聪明。因此尝试为所有 UIWebView 设置通用加载方法。但它没有用。用类别实现是错误的吗?
UIWebView+Loading.m
-(void)webViewDidStartLoad:(UIWebView*)webView
{
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES];
}
视图控制器.h
@interface ViewController : UIViewController <UIWebViewDelegate>
视图控制器.m
#import "UIWebView+Loading.h"
//abbr...
-(void)viewWillAppear:(BOOL)animated
{
UIWebView *someWebView = [[UIWebView alloc] init];
someWebView.delegate = self;
//and HTTP request
NSURLRequest *req = (abbr);
[someWebView loadRequest:req];
}