setMessageBody 中忽略新行和返回
我是不是在做一些蠢事?我可以预填写并发送电子邮件,但电子邮件正文中的“\r\n”被忽略:
- (void) sendEventInEmail
{
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
NSString *emailSubject = [eventDictionary objectForKey:EVENT_NAME_KEY];
[picker setSubject:emailSubject];
// Fill out the email body text
NSString *iTunesLink = @"http://itunes.apple.com/gb/app/whats-on-reading/id347859140?mt=8"; // Link to iTune App link
NSString *content = [eventDictionary objectForKey:@"Description"];
NSString *emailBody = [NSString stringWithFormat:@"%@\r\nSent using <a href = '%@'>What's On Reading</a> for the iPhone.", content, iTunesLink];
[picker setMessageBody:emailBody isHTML:YES];
picker.navigationBar.barStyle = UIBarStyleBlack;
[self presentModalViewController:picker animated:YES];
[picker release];
}
问候
戴夫
Am I doing something dumb? I can pre-fill and email ok but the "\r\n" is ignored in the emailBody:
- (void) sendEventInEmail
{
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
NSString *emailSubject = [eventDictionary objectForKey:EVENT_NAME_KEY];
[picker setSubject:emailSubject];
// Fill out the email body text
NSString *iTunesLink = @"http://itunes.apple.com/gb/app/whats-on-reading/id347859140?mt=8"; // Link to iTune App link
NSString *content = [eventDictionary objectForKey:@"Description"];
NSString *emailBody = [NSString stringWithFormat:@"%@\r\nSent using <a href = '%@'>What's On Reading</a> for the iPhone.", content, iTunesLink];
[picker setMessageBody:emailBody isHTML:YES];
picker.navigationBar.barStyle = UIBarStyleBlack;
[self presentModalViewController:picker animated:YES];
[picker release];
}
Regards
Dave
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果 isHTML 设置 YES \n 不起作用,您必须设置 isHTML:NO 或使用 HTML 换行符,例如
输入>新行。
<代码>
插入一个新的段落,这通常意味着双换行符。
尝试使用 isHTML:YES:
如果 isHTML:NO 只需输入 \n
它会给你这个:
第一行
第二行
第三行
依此类推...
If isHTML set YES \n does not work you either have to set isHTML:NO or use a HTML line break such as
<br />
to enter a new line.<p> </p>
inserts a new paragraph which usually means double line break.Try this with isHTML:YES:
If isHTML:NO just put \n
It will give you this:
1st line
2nd line
3rd line
and so on...
Doh...一直在努力将 Objective C 字符串与 HTML 混合在一起。使用
和
标签进行修复。
戴夫
Doh... been working too hard and mixing Objective C strings with HTML. Used
<p>
and</p>
tags to fix.Dave