【问题标题】:Entering line breaks in NSString在 NSString 中输入换行符
【发布时间】:2010-12-31 14:23:16
【问题描述】:

我需要在 MFMailComposeViewController 中设置邮件正文以分隔一些文本的行数。我正在使用以下代码行,但它不起作用。

[mail setMessageBody:[NSString stringWithFormat:@"Hi I am Interested to buy a vehicle for me Name :%@ %@ \n Contact No. : %@ \n Email : %@\n",txtFirst.text, txtLast.text, txtContact.text, txtEmail.text ] isHTML:YES];

我也试过了

[mail setMessageBody:[NSString stringWithFormat:@"Hi I am Interested to buy a vehicle for me Name :%@ %@ </br> Contact No. : %@ </br> Email : %@</br>",txtFirst.text, txtLast.text, txtContact.text, txtEmail.text ] isHTML:YES];

有什么解决办法吗。

【问题讨论】:

    标签: iphone iphone-sdk-3.0 mfmailcomposeviewcontroller


    【解决方案1】:

    试试这个

    [mail setMessageBody:
    [NSString stringWithFormat:@"First:%@
                               \r\n Second:%@
                               \r\n Third:%@
                               \r\n Fourth:%@",
    txtFirst.text, txtSecond.text, txtThird.text, txtFourth.text ] isHTML:YES];
    

    【讨论】:

      【解决方案2】:

      如果您在消息中将isHTML 设置为YES,请使用&lt;br/&gt; 进行换行,如果isHTML 为NO,请使用\r\n

      【讨论】:

        【解决方案3】:

        您的 messageBody 设置为 HTML,这意味着您需要添加 &lt;/ br&gt; 换行,或设置 isHTML:NO

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2020-01-10
          • 2015-09-30
          • 2011-08-14
          相关资源
          最近更新 更多