我有一个显示网站的 iPhone 应用程序。该网站不时更改其内容,但我的应用程序每次打开时都不会重新加载。我试图阻止网站的缓存,但没有成功。
这是我的初始化方法:
- (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;
}
这是我的 viewWillAppear 方法:
- (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;
}
请帮我解决这个问题。非常感谢所有答案。