Tôi có một ứng dụng iPhone hiển thị một trang web. Trang web này thay đổi nội dung của nó theo thời gian nhưng ứng dụng của tôi không tải lại nó mỗi khi nó được mở. Tôi đã cố gắng để ngăn chặn bộ nhớ đệm của trang web, nhưng không thành công.iOS: Buộc UIWebView tải lại/ngăn chặn bộ nhớ đệm
Đây là phương pháp init của tôi:
- (id)init:(NSString *)url withTitle:(NSString *)theTitle withPageName:(NSString *)pageName {
self = [super init];
if(self) {
NSLog(@"websiteviewcontroller init");
self.title = theTitle;
self.url = url;
self.pageName = pageName;
CGRect frame = [[UIScreen mainScreen] applicationFrame];
webView = [[UIWebView alloc] initWithFrame:frame];
NSURL *theURL = [NSURL URLWithString:url];
[webView loadRequest:[NSURLRequest requestWithURL:theURL]];
// support zooming
webView.scalesPageToFit = YES;
//[[NSURLCache sharedURLCache] removeAllCachedResponses];
[webView reload];
}
return self;
}
Đây là tôi viewWillAppear-Phương pháp:
- (void)viewWillAppear:(BOOL)animated {
CGRect frame = [[UIScreen mainScreen] applicationFrame];
webView = [[UIWebView alloc] initWithFrame:frame];
NSURL *theURL = [NSURL URLWithString:url];
[webView loadRequest:[NSURLRequest requestWithURL:theURL]];
[webView reload];
// support zooming
webView.scalesPageToFit = YES;
}
Xin hãy giúp tôi để giải quyết vấn đề này. Tất cả các câu trả lời đều được đánh giá cao.