//要实现UIWebViewDelegate代理
@interface TestViewController : UIViewController<UIWebViewDelegate>
{
UIWebView *protWebView;
}
@property (retain, nonatomic) IBOutletUIWebView *protWebView;
@implementation TestViewController
@synthesize protWebView;
- (void)viewDidLoad
{
NSLog(@"viewDidLoad");
[superviewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
NSURL *url = [[NSURL alloc]initWithString:@"http://www.baidu.com"];
[protWebViewloadRequest:[NSURLRequestrequestWithURL:url]];
}
//几个代理方法
- (void)webViewDidStartLoad:(UIWebView *)webView{
NSLog(@"webViewDidStartLoad");
}
- (void)webViewDidFinishLoad:(UIWebView *)web{
NSLog(@"webViewDidFinishLoad");
}
-(void)webView:(UIWebView*)webView DidFailLoadWithError:(NSError*)error{
NSLog(@"DidFailLoadWithError");
}