我的目標是在iOS上使用UIWebView構建一個Web應用程序,基本上可以做BlackBerry爲Webworks所做的一切。iOS UIWebView緩存問題
閱讀後左右我留下不確定緩存是如何工作的,所以我嘗試了以下測試:
用的「Hello World」創建簡單的Web應用程序開始。
構建&運行應用程序 - 運行良好
然後改變了login.html的(那是什麼我的Hello World叫)我所做的更改是我reaplced的Hello World,並鏈接到另一個頁面。
當我建立&再次運行舊頁面仍然顯示。
所以我假設有緩存的地方?
有無論如何去做以下/什麼是最好的?
- 禁用緩存爲速度並不重要我們所有的文件都在磁盤上?
- 每次啓動應用程序時清除緩存?
有沒有人遇到過這個?
感謝
我曾嘗試: How to delete the cache from UIWebview or dealloc UIWebview
另一個更新------
嘗試另一種簡單的測試,我刪除了我的HTML文件夾中所有的HTML,CSS,JS文件在它現在在垃圾中。再次運行該應用程序並刪除項目中的html引用,它仍然會加載它們全部完美。所以整個事情都緩存在某個地方。
至於另一次嘗試,我也補充說:
-(void)dealloc{
self.webView.delegate = nil;
self.webView = nil;
[webView release];
[super dealloc];
}
在NativeViewController.m這並沒有幫助。
我的應用程序代碼:`
#import "NativeViewController.h"
@implementation NativeViewController
@synthesize webView;
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
[super viewDidLoad];
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"login" ofType:@"html"];
NSData *htmlData = [NSData dataWithContentsOfFile:filePath];
if (htmlData) {
NSBundle *bundle = [NSBundle mainBundle];
NSString *path = [bundle bundlePath];
NSString *fullPath = [NSBundle pathForResource:@"login" ofType:@"html" inDirectory:path];
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:fullPath]]];
}
}
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
- (void)viewDidUnload {
[self.webView removeFromSuperview];
self.webView.delegate = nil;
self.webView = nil;
}
-(void)webViewDidFinishLoad{
[[NSURLCache sharedURLCahce] removeAllCachedResponses];
}
- (void)dealloc {
[webView release];
[super dealloc];
}
@end
`
你的.html文件是捆綁在一起的嗎? – Dhara
是在構建階段,包含所有HTML文件的文件夾在那裏:它說:「複製束資源」「HTML」,帶有藍色文件夾圖標,然後是MainWindow.xib,NativeViewController.xib,MainWindow-iPad。包中的xib – LmC
是否意味着它已添加到您的項目中?做一個事情重置模擬器,然後嘗試 – Dhara