インラインスタイルを作成するとレンダリングされますが、xCode内の同じグループとディレクトリにあるcssファイルを参照しようとすると、レンダリングされません。
これが私がすることです:
<html>
<head>
<link href="main.css" rel="stylesheet" type="text/css" />
</head>
<body>
<h1>Hello, world! Learn</h1>
<p>
<a href="myscheme://advertising" class="buttonStyle">Click me!</a>
</p>
</body>
</html>
そして、次のようなmain.cssというcssファイルがあります。
body {background-color:#b0c4de;}
p {background-color:#e0ffff;}
なぜこれがCSSをレンダリングしないのか誰かが知っていますか?HTMLヘッダーから重要なものが欠落していますか?
そもそもHTMLを呼び出す方法は次のとおりです。
- (void)viewDidAppear:(BOOL)animated
{
NSString *htmlFile = [[NSBundle mainBundle] pathForResource:@"learn"
ofType:@"html"];
NSString* htmlString = [NSString stringWithContentsOfFile:htmlFile encoding:NSUTF8StringEncoding error:nil];
[theWebView loadHTMLString:htmlString baseURL:nil];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:htmlFile]];
[theWebView loadRequest:request];
}