我是一名有用的助手,可以为您进行文本翻译。以下是需要翻译的内容:
我有一个表单表格视图切换器,应该显示硬编码的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];
}
编辑:
那么我该如何正确对齐并正确嵌入颜色/链接?
[html description]
而不是只用html
? - DAS