2011-08-30 5 views
3

사용자가 메일을 보낼 때 표시 할 UITextViews가 두 개인 있습니다. 문제는 두 번째 텍스트 뷰의 텍스트를 메일의 새 줄에 표시하기 위해서입니다.NSString 새 줄이 메일에서 작동하지 않습니까?

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의 피커 * = [MFMailComposeViewController의 ALLOC] INIT]; picker.mailComposeDelegate = self; 단지 html 태그를 사용하여 구성 메일에서

[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]; 

}

+0

MFMailComposer에서이 텍스트를 설정하는 위치를 알려주시겠습니까? – MishieMoo

+0

질문에 코드를 추가하고 적절하게 형식을 지정해야한다고 생각합니다. 나는 그것을 읽을 수 없다. – Hyperbole

답변

5

는 그것을 잘 작동합니다.
새 줄에 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); 
+0

고마워요! 도와 주셔서 감사합니다. – ftwhere

관련 문제