ハードコードされたhtmlページを表示する必要があるフォームシートセグがあります。 今、私は2つの部分の問題最初の問題を抱えている、私はそれが動作する場合には<left>
に<CENTER>
タグを変更することができますUIWebView IOSでのHTMLコンテンツの表示方法
<CENTER><H1>A Simple Sample Web Page</H1><H4>By Frodo</H4>
<H2>Demonstrating a few HTML features</H2></CENTER>
が
のように表示されているが、それは私のオプションを制限します。このコンテンツを表示するにはどうすればよいですか?
質問の第2の部分は、コンテンツに色やリンクを埋め込む方法です。ライン""FFFFFF">\n"
に私はExpected ':'
とライン上のラインの"<a href="http://somegreatsite.com">\n"
半分はあるグリーンであることが
私の完全なコードは次のようであるXCodeので実行しないことを意味し、画面上のコメントのように思えるが言うエラーが出る:
- (void) createWebViewWithHTML{
//create the string
NSMutableString *html = [NSMutableString stringWithString: @"<html><head><title></title></head><body style=\"background:transparent;\">"];
//continue building the string
[html appendString:@"<BODY BGCOLOR="
""FFFFFF">\n"
"<CENTER><IMG SRC="clouds.jpg" ALIGN="BOTTOM">
"</CENTER> \n"
"<HR>\n"
"<a href="http://somegreatsite.com">\n"
"Link Name</a>\n"
"is a link to another nifty site\n"
"<H1>This is a Header</H1>\n"
"<H2>This is a Medium Header</H2>\n"
"Send me mail at <a href="mailto:[email protected]">\n"
"[email protected]</a>.\n"
"<P> This is a new paragraph!\n"
"<P> <B>This is a new paragraph!</B>\n"
"<BR> <B><I>This is a new sentence without a paragraph break, in bold italics.</I></B>\n"
"<HR>\n"];
[html appendString:@"</body></html>"];
//instantiate the web view
webView = [[UIWebView alloc] initWithFrame:self.view.frame];
//make the background transparent
[webView setBackgroundColor:[UIColor clearColor]];
//pass the string to the webview
[webView loadHTMLString:[html description] baseURL:nil];
//add it to the subview
[self.view addSubview:webView];
}
編集:: 追加ストーリーボードの画像
それでは、どのように私は正しいalignmを作ることができます色とリンクを正しく埋め込みますか?
WebView = [[UIWebView alloc] initWithFrame:self.view]を実行してみてください。 ** bounds **];フレームの代わりに – Charan
なぜ '[html description]' の代わりに 'html'ですか? – DAS
それはあなたがwebviewに文字列を渡す方法ではありませんか? –