gpt4 book ai didi

iphone - NSString 新行在邮件中不起作用?

转载 作者:行者123 更新时间:2023-12-03 19:39:12 28 4
gpt4 key购买 nike

我有两个 UITextView,我想在用户发送邮件时显示它们。问题是我希望第二个 TextView 中的文本显示在邮件的新行中。

我尝试过使用 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 = 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];

}

最佳答案

在撰写邮件时只需使用 html 标签即可正常工作。
使用html <br />标记新行。

NSString *desc = descriptionTextView.text;
NSString *ingredients = ingredientsTextView.text;
NSString *emailBody = [NSString stringWithFormat:@"%@ <br/> <br/> %@", desc, ingredients];
// [email setMessageBody:emailBody isHTML:YES];
NSLog(@"%@\n\n%@", desc, ingredients);

关于iphone - NSString 新行在邮件中不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7245501/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com