我有一張表格segue,應該顯示硬編碼的html頁面。 現在我有兩個部分的問題第一個問題是如何在UIWebView上顯示html內容IOS
<CENTER><H1>A Simple Sample Web Page</H1><H4>By Frodo</H4>
<H2>Demonstrating a few HTML features</H2></CENTER>
顯示像
我可以在它的工作原理這種情況下,改變<CENTER>
標籤<left>
但是它限制了我的選擇。如何顯示此內容在屏幕中間沒有對齊問題?
問題的第二部分是如何嵌入顏色或內容鏈接。在線""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。 **界限**];而不是幀 – Charan
爲什麼'[html description]' 而不是'html'? – DAS
是不是你如何傳遞字符串到webview? –