无法使webViewDidStartLoad和webViewDidFinishLoad工作

时间:2011-03-15 04:16:37

标签: iphone objective-c cocoa-touch ios uiwebview

Web视图加载页面。它不会调用webViewDidStartLoadwebViewDidFinishLoad方法。

N_NumberAppDelegate.h:

@interface N_NumberAppDelegate : UIViewController <UIWebViewDelegate> {
    UIWindow *window;
}

@property (nonatomic, retain) IBOutlet UIWindow *window;

@end

N_NumberAppDelegate.m:

@implementation N_NumberAppDelegate

@synthesize window;

- (void)applicationDidFinishLaunching:(UIApplication *)application {

    UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 20, 320, 480)];
    [webView  loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://registry.faa.gov/aircraftinquiry/NNum_Results.aspx?NNumbertxt=2N"]]];
    [window addSubview:webView];
    [window makeKeyAndVisible];
    [window release];
}

- (void)webViewDidStartLoad:(UIWebView *)webView {
    NSLog(@"Started loading");
}

- (void)webViewDidFinishLoad:(UIWebView *)webView {
    NSLog(@"Finshed loading");
}

1 个答案:

答案 0 :(得分:20)

我想你忘了设置你的代表了。 即webView.delegate=self;

祝你好运