【问题标题】:Inserting data into HTML via Objective-C通过 Objective-C 将数据插入 HTML
【发布时间】:2012-07-03 05:07:37
【问题描述】:

我想在 Objective-c 中添加一个热 html 链接到一封电子邮件。我知道,如果我有一个特定的 url,它通常的工作方式是:

[composer setMessageBody:[NSString stringWithFormat:@"Example text, 
<a href=\"google.com\">Link Name</a> More example text"];

但我希望有一个带有自定义生成 url 的热链接作为链接的标题和链接的网站,所以更像:

[composer setMessageBody:[NSString stringWithFormat:@"Example text, 
<a href=%@>%@</a>", self.link, self.link];

但这让我崩溃了。想法?

【问题讨论】:

  • 除了缺少的],href 的值应该用href=\"%@\" 之类的引号括起来。您也可以使用href='%@'。

标签: html objective-c email hyperlink


【解决方案1】:

您没有关闭此声明:

[composer setMessageBody:[NSString stringWithFormat:@"Example text, 
<a href=%@>%@</a>", self.link, self.link];

最后需要另一个右方括号。

另外,您应该将 href 值用引号括起来,当然要转义。

\" value \"

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-06-21
    • 1970-01-01
    • 1970-01-01
    • 2019-10-21
    • 1970-01-01
    相关资源
    最近更新 更多