1

Web接続のないiPadでWebフォームを実行しようとしています。これまでのところ、htmlファイルを取得してブラウザーに表示するアプリを使用して、フォームをサファリにロードすることに成功しました。

ただし、html5のデータストア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];
4

1 に答える 1

3

問題は、Xcodeが私のjsファイルをコンパイルしようとすることでした。DAMN YOU APPLE!

とにかく、プロジェクトを開いているときは、xcodeのアイテムのリストの右側を見てください

ターゲットを探してください。弓と矢のターゲットの写真、または赤と白のダーツボードのようなものがあります。それを開いて、コンパイルされたリソースを見てください。そこからjsファイルをコピーバンドルリソースに移動します。

バム!すべてが意図したとおりに機能するはずです。

于 2011-03-21T11:34:02.187 に答える