It seems there isn’t a direct way to clear the content of a WebView before loading a new URL. If you have a TableView and every cell contains a link which push a WebView to display a link, the web previously loaded is display until the new link start loading.
The best way I found to clear out the previous content is to load an empty html file (stored on the resources) on the viewWillDisappear
as in the following code:
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
NSString *htmlPath = [[NSBundle mainBundle] pathForResource:@"blank" ofType:@"html" ];
NSURL *url = [[NSURL alloc] initFileURLWithPath: htmlPath];
NSURLRequest *request = [[NSURLRequest alloc] initWithURL: url];
[myWebView loadRequest: request];
[request release];
[url release];
}