我正在尝试在没有网络连接的 ipad 上运行网络表单。到目前为止,我已经成功地通过使用一个应用程序将表单加载到 safari 中,该应用程序需要一个 html 文件并在浏览器中显示它。
但是,html 5 的数据存储 sql 组件似乎不起作用。我从 html5rocks.com http://playground.html5rocks.com/#async_transactions复制了代码 似乎可以在任何地方工作,但在我的应用程序中。
所以我的应用程序非常简单,它只是加载一个网络浏览器......这是相关代码
- (void)viewDidLoad {
// Example 1, loading the content from a URLNSURL
//NSURL *url = [NSURL URLWithString:@"http://dblog.com.au"];
//NSURLRequest *request = [NSURLRequest requestWithURL:url];
//[webView loadRequest:request];
NSString *webPage = [[NSBundle mainBundle] pathForResource:@"index" ofType:@"html"];
NSData *webData = [NSData dataWithContentsOfFile:webPage];
NSString *imagePath = [[NSBundle mainBundle] resourcePath];
imagePath = [imagePath stringByReplacingOccurrencesOfString:@"/" withString:@"//"];
imagePath = [imagePath stringByReplacingOccurrencesOfString:@" " withString:@"%20"];
// NSString *HTMLData = @"
// <h1>Hello this is a test</h1>
// <img src="sample.jpg" alt="" width="100" height="100" />";
// [webView loadHTMLString:HTMLData baseURL:[NSURL URLWithString: [NSString stringWithFormat:@"file:/%@//",imagePath]]];
//[webView loadHTMLString:webPage baseURL:[NSURL URLWithString: [NSString stringWithFormat:@"file:/%@//",imagePath]]];
//[webView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:webPage isDirectory:NO]]];
NSString *baseStr = [NSString stringWithFormat:@"file:/%@//",imagePath];
NSURL *baseURL = [NSURL URLWithString: baseStr];
NSLog(@"%@",baseStr);
//webView.scalesPageToFit = YES;
//webView.multipleTouchEnabled = YES;
/*for (id subview in webView.subviews){
if([[subview class] isSubclassOfClass: [UIScrollView class]])
((UIScrollView *)subview).bounces = NO;
}*/
[webView loadData:webData MIMEType:@"text/html" textEncodingName:@"UTF-8" baseURL:baseURL];
//[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.cyberdesignworks.com.au/clients/ideatoaction"]]];
//[webView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"Test" ofType:@"svg"]isDirectory:NO]]];
[super viewDidLoad];