我想停止WebPage加载UIWebView,同时传递另一个URL进行加载。
答案 0 :(得分:5)
你应该实现:
- (BOOL)webView:(UIWebView *)inWeb shouldStartLoadWithRequest:(NSURLRequest *)inRequest navigationType:(UIWebViewNavigationType)inType
UIWebViewDelegate
协议的方法,并为您不想加载的所有网址返回NO
。
示例:
- (BOOL)webView:(UIWebView *)inWeb shouldStartLoadWithRequest:(NSURLRequest *)inRequest navigationType:(UIWebViewNavigationType)inType {
if ([[inRequest URL] isEqual:someMyUrl]) {
return YES;
}
return NO;
}
答案 1 :(得分:1)
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"about:blank"]]];