以下のようなhtml、css、js、および画像を含むフォルダー構造をxcodeプロジェクトに含めようとしています。
htmlcontent
html
test.html
css
test.css
js
test.js
フォルダとそのサブフォルダをxcodeにコピーすると、そこにheirachyが表示されますが、次のようにすると次のようになります。
NSString *pathToFile = [[NSBundle mainBundle] pathForResource:@"test" ofType:@"html"];
NSURL *url = [NSURL fileURLWithPath:pathToFile isDirectory:NO];
[_webView loadRequest:[NSURLRequest requestWithURL:url]];
印刷します:
/Users/scoota/Library/Application Support/iPhone Simulator/6.0/Applications/8AAC5870-DF24-49BB-BCB8-598C8C0A7C9A/TestApp.app/test.html
階層を維持する方法はありますか?私が尋ねる理由は、私のhtmlファイルに次のようなcssへの参照があるからです。
<link rel="stylesheet" type="text/css" href="htmlcontent/test.css" media="screen, projector" />
その結果、cssはロードされません。次のように変更すると:
<link rel="stylesheet" type="text/css" href="test.css" media="screen, projector" />
ロードします。
何かご意見は?