0

좋습니다. 더 나은 질문을하도록하겠습니다.uitableview에서 전자 메일 본문을 채우는 가장 좋은 방법

사용자가 tableview에서 해당 데이터를 이메일로 보내고 싶다는 일부 정보가 포함 된 tableViewController가 있습니다.

해당 정보가있는 배열을 유지할 수 있습니다.

질문의 힘든 부분은 objective-C 언어를 사용하여 내 tableview의 데이터로 메시지 본문을 채우는 방법입니다.

모든 HTML 코드가 포함 된 거대한 문자열을 만들어야합니까? 아니면 주위에 더 좋고/더 쉬운 방법이 있습니까? 단순한 테이블이라 할지라도 클라이언트는 누군가에게 그것을 보낼 것입니다.

나는 모든 솔루션/조언이 내가이 일을 어떻게해야하는지 알 수있는 훌륭한 웨이 포인트가 될 것 같아.

+0

"비슷한 모양"이란 무엇을 의미합니까? 문자 그대로 테이블보기의 스크린 샷과 같은 것을 원하십니까? 또는 행에 항목을 배치하고 싶습니까? –

+2

html + css 나는 추측하고있다. – chown

+0

@quixoto : 스크린 샷은 항목을 더 이상 캡처하지 않아 스크롤 할 수 없으므로 작동하지 않습니다. 따라서 항목을 레이아웃하고 싶습니다. 형식을 지정하는 방법에 대한 아이디어가 있습니까? 나는 거기에 배열을 던져 넣을 수 있지만 추한 것처럼 보일 것이다. – Farini

답변

5

나는 그것을 괴롭혔다! 여러분이 UITableViewController의 데이터를 가지고있는 이메일을 작성하고 싶다면 여기에 제가 작성한 방법이 있습니다. 그냥

#import Recipe.h //in the implementation file 
#import Ingredients.h //in the implementation file 
#import <MessageUI/MFMailComposeViewController.h> // this line gotta be in the header file 

-(IBAction)sendmail{ 
MFMailComposeViewController *composer = [[MFMailComposeViewController alloc] init]; 
[composer setMailComposeDelegate:self]; 
NSString *recipeTitle = @"<h5>Recipe name: "; 
recipeTitle = [recipeTitle stringByAppendingFormat:recipe.name]; 
recipeTitle = [recipeTitle stringByAppendingFormat:@"</h5>"]; 

NSString *ingredientAmount = @""; 
NSString *ingredientAisle = @""; 
NSString *ingredientTitle = @""; 

NSString *tableFirstLine = @"<table width='300' border='1'><tr><td>Ingredient</td><td>Amount</td><td>Aisle</td></tr>"; 
NSString *increments = @""; 
increments = [increments stringByAppendingFormat:recipeTitle]; 
increments = [increments stringByAppendingFormat:tableFirstLine]; 
int i; 

for (i=0; i < [ingredients count]; i++) { 
    Ingredient *ingredient = [ingredients objectAtIndex:i]; 
    ingredientTitle = ingredient.name; 
    ingredientAmount = ingredient.amount; 
    ingredientAisle = ingredient.aisle; 

    increments = [increments stringByAppendingFormat:@"<tr><td>"]; 
    increments = [increments stringByAppendingFormat:ingredientTitle]; 
    increments = [increments stringByAppendingFormat:@"</td><td>"]; 
    increments = [increments stringByAppendingFormat:ingredientAmount]; 
    increments = [increments stringByAppendingFormat:@"</td><td>"]; 
    increments = [increments stringByAppendingFormat:ingredientAisle]; 
    increments = [increments stringByAppendingFormat:@"</td></tr>"]; 
    if (i == [ingredients count]) { 
     //IF THIS IS THE LAST INGREDIENT, CLOSE THE TABLE 
     increments = [increments stringByAppendingFormat:@"</table>"]; 
    } 
} 

NSLog(@"CODE:: %@", increments); 

if ([MFMailComposeViewController canSendMail]) { 
    [composer setToRecipients:[NSArray arrayWithObjects:@"[email protected]", nil]]; 
    [composer setSubject:@"subject here"]; 
    [composer setMessageBody:increments isHTML:YES]; 
    [composer setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal]; 
    [self presentModalViewController:composer animated:YES]; 
    [composer release]; 
}else { 
    [composer release]; 
    } 
} 

이 하나

나에게 큰 단계이고 앱에서 흥미로운 (기본) 도구를 만들려면 실제로 매우 유용합니다 ... 당신의 데이터를 헤더 파일을 가져 기억한다. 객관적인 c 프로그래머를위한이 전형적인 웹 사이트의 모든 분들께 감사드립니다.

Andis는 결과입니다. 간단하지만 시작하는 좋은 방법.

enter image description here

+0

약속대로. 여기에 스크린 샷이 있습니다. 아주 간단한 테이블이지만 기본은 모두 여기에 있습니다. – Farini

관련 문제