Every time I load a new page with UIWebView
the before loaded page is shown for a short time.
How can I clear that cache? Another possibility would be to dealloc UIWebview
. I tried that but than my UIWebView
is always "empty". How should the alloc
and dealloc
be done in this case?
I noticed that the UIWebView
is consuming about 10 MB RAM. Now the UIWebView
is loaded together with the ViewController
. And the view is autoreleased as well as the UIWebView
is autoreleased. Wouldn't it be better to dealloc the WebView each time?
Solution:
- (void) viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
CGRect frame = CGRectMake(0, 0, 320, 480);
self.webView = [[[UIWebView alloc]initWithFrame:frame] autorelease];
self.webView.scalesPageToFit = YES;
[self.view addSubview:self.webView];
}
- (void) viewDidDisappear:(BOOL)animated {
[super viewDidDisappear:animated];
[self.webView removeFromSuperview];
self.webView = nil;
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…