我做的事情是愚蠢的吗?我可以预先填写并发送电子邮件,但在电子邮件中忽略了“\ 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];
}
此致
戴夫
答案 0 :(得分:28)
如果isHTML设置为YES \ n无效,您必须设置isHTML:NO或使用HTML换行符(例如 <br />
)输入新行。
<p> </p>
会插入新的段落,这通常意味着双线换行。
使用isHTML尝试:YES:
[picker setMessageBody:@"1st line<br />2nd line<br />3rd line<br />and so on..." isHTML:YES];
如果isHTML:NO只是把\ n
[picker setMessageBody:@"1st line\n2nd line\n3rd line\nand so on..." isHTML:NO];
它会给你这个:
第1行
第2行第3行
等等......
答案 1 :(得分:4)
Doh ...一直在努力工作并将Objective C字符串与HTML混合。使用<p>
和</p>
标记进行修复。
戴夫