开发者

NSString new line doesn't work in mail?

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];
NS开发者_Go百科String *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];

}


In mail composing just use the html tags then it works fine.
Use a html <br /> tag for a new line.

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);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜