我已经研究和研究,但仍然不明白为什么从未调用过StartLoadWithRequest.我的页面加载正常,并调用了一些UIWebview委托协议方法.请从以下代码中找到相关的摘要:
在我的.m中合成我的webview(在头文件中定义):
@H_502_4@@implementation PortViewController @synthesize WebView = myWebView;我成功加载了我的webview:
@H_502_4@myURLString = [NSString stringWithFormat:@"https://%@",defaultWebsite]; myURL = [NSURL URLWithString: myURLString]; NSURLRequest *myRequest = [NSURLRequest requestWithURL:myURL]; [myWebView loadRequest:myRequest];把我的代表设置为自己
@H_502_4@- (void)viewDidLoad { [super viewDidLoad]; [myWebView setOpaque:NO]; [myWebView setBackgroundColor:[UIColor clearColor]]; //myWebView.description. myWebView.delegate = self; }我的所有协议方法都被称为EXCEPT shouldStartLoadWithRequest
@H_502_4@- (void)webViewDidStartLoad:(UIWebView *)myWebView { [activityIndicator startAnimating]; } - (void)webViewDidFinishLoad:(UIWebView *)myWebView { [activityIndicator stopAnimating]; } - (BOOL)WebView:(UIWebView *)myWebView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType { NSLog(@"inside Webview"); if([[request.URL absoluteString] hasPrefix:@"http://www.nzx"]) { // do stuff NSLog(@"Have caught the prefix"); return YES; } return NO; }提前致谢.