【发布时间】:2011-12-21 18:50:39
【问题描述】:
我有一个本地存储,用于在程序中运行 web 视图,但它总是在下一个程序运行开始时被清除。我检查了文件,它在程序运行后确实存在,但在下一个程序开始时,它会清除它。
这是我的代码:
- (void)awakeFromNib {
WebPreferences *prefs = [webView preferences];
[prefs _setLocalStorageDatabasePath:@"~/Library/Application Support/MyApp"];
[prefs setDatabasesEnabled:YES];
[prefs setLocalStorageEnabled:YES];
NSString *resourcesPath = [[NSBundle mainBundle] resourcePath];
NSString *htmlPath = [resourcesPath stringByAppendingString:@"/htdocs/index.html"];
[[webView mainFrame] loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:htmlPath]]];
[window setDelegate:self];
}
任何帮助将不胜感激!谢谢
【问题讨论】:
-
哦,这不适用于 iOS。我应该在下面阅读您的免责声明。以下两个链接可能对您仍然有用:stackoverflow.com/questions/2640724stackoverflow.com/questions/4625484/…
-
我在发布之前检查了这两个,但找不到有用的信息。我知道本地存储应该是可能的,因为它只是一个嵌入式 webkit。
-
这在 10.7 和 Xcode 4.3.3 上对我有用:stackoverflow.com/questions/10609644/…
标签: cocoa webview local-storage