NSString 新行在邮件中不起作用?
我有两个 UITextView,我想在用户发送邮件时显示它们。问题是我希望第二个文本视图中的文本显示在邮件的新行中。
我尝试过使用 NSLog,它在那里工作得很好,邮件 API 是否有问题或者为什么不能正常工作?
我的代码如下所示:
NSString *desc = descriptionTextView.text;
NSString *ingredients = ingredientsTextView.text;
NSString *emailBody = [NSString stringWithFormat:@"%@\n\n%@", desc, ingredients];
NSLog(@"%@\n\n%@", desc, ingredients);
-(void)displayComposerSheet
{ MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init]; picker.mailComposeDelegate = 自我;
[picker setSubject:titleLabel.text];
NSString *desc = descriptionTextView.text;
NSString *ingredients = ingredientsTextView.text;
NSString *emailBody = [NSString stringWithFormat:@"%@\n\n%@", desc, ingredients];
NSLog(@"%@\n\n%@", desc, ingredients);
[picker setMessageBody:emailBody isHTML:YES];
[self presentModalViewController:picker animated:YES];
[picker release];
}
- (void)viewDidLoad {
titleLabel.text = [recipeData valueForKey:@"title"];
descriptionTextView.text = [recipeData valueForKey:@"description"];
ingredientsTextView.text = [recipeData valueForKey:@"ingredients"];
[super viewDidLoad];
}
I have two UITextViews that I want to be displayed when the user sends mail. The problem is that I want the text from the second textview to be displayed in a new line in the mail.
I've tried with NSLog and it works just fine there, is there a problem with the mail API or why is not working properly?
My code looks like this:
NSString *desc = descriptionTextView.text;
NSString *ingredients = ingredientsTextView.text;
NSString *emailBody = [NSString stringWithFormat:@"%@\n\n%@", desc, ingredients];
NSLog(@"%@\n\n%@", desc, ingredients);
-(void)displayComposerSheet
{
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
[picker setSubject:titleLabel.text];
NSString *desc = descriptionTextView.text;
NSString *ingredients = ingredientsTextView.text;
NSString *emailBody = [NSString stringWithFormat:@"%@\n\n%@", desc, ingredients];
NSLog(@"%@\n\n%@", desc, ingredients);
[picker setMessageBody:emailBody isHTML:YES];
[self presentModalViewController:picker animated:YES];
[picker release];
}
- (void)viewDidLoad {
titleLabel.text = [recipeData valueForKey:@"title"];
descriptionTextView.text = [recipeData valueForKey:@"description"];
ingredientsTextView.text = [recipeData valueForKey:@"ingredients"];
[super viewDidLoad];
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在撰写邮件时只需使用 html 标签即可正常工作。
使用 html
标签作为新行。In mail composing just use the html tags then it works fine.
Use a html
<br />
tag for a new line.