我有这段代码用于在emailMessageBody中显示一些内容。代码如下。
var emailViewController : MFMailComposeViewController = MFMailComposeViewController()
emailViewController.mailComposeDelegate = self
emailViewController.setToRecipients(["----"])
emailViewController.setSubject("----")
emailViewController.setMessageBody("\n\n\n" + "-- \r\n " + "----- Device : \(self.deviceName), App Version : \(self.appVersion), Model : \(deviceModel) , iOS Version : \(self.deviceVersion), Country Code : \(self.countryCode), Localised Model : \(deviceLocalizedModel) \n \n \n", isHTML: true)
self.presentViewController(emailViewController, animated: true, completion: nil)
你们看到我把" \ n"在内容中,但它没有在emailBody中显示新行。 如果有人知道如何在emailMessageBody中获得一些新行,请帮助。
答案 0 :(得分:4)
您需要使用</br>
代替\n
因此,您的示例代码将如下所示
var emailViewController : MFMailComposeViewController = MFMailComposeViewController()
emailViewController.mailComposeDelegate = self
emailViewController.setToRecipients(["----"])
emailViewController.setSubject("----")
emailViewController.setMessageBody("</br></br></br>" + "-- </br> " + "----- Device : \(self.deviceName), App Version : \(self.appVersion), Model : \(deviceModel) , iOS Version : \(self.deviceVersion), Country Code : \(self.countryCode), Localised Model : \(deviceLocalizedModel) </br></br></br>", isHTML: true)
self.presentViewController(emailViewController, animated: true, completion: nil)
答案 1 :(得分:1)
如果您想使用\n
,则必须在isHTML
来电中将参数false
设置为setMessageBody
,否则您必须使用</br>
代替设置邮件正文的内容时\n
。