我有一个表单segue,应该显示硬编码的html页面。现在我有一个两部分的问题第一个问题是
<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:support@yourcompany.com">\n"
"support@yourcompany.com</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];
}
编辑:: 添加故事板图片
那么如何正确对齐并正确嵌入颜色/链接?