2012-07-11 45 views
0

我已將messageUI框架包含在我的應用程序中用於發送郵件。它包含五個UITextField,其中用戶輸入的值應顯示在郵件正文中。這裏是我的代碼未顯示UITextField內容的MessageUI框架問題

if ([MFMailComposeViewController canSendMail]) 
{ 
    MFMailComposeViewController *mailer = [[MFMailComposeViewController alloc] init]; 

    mailer.mailComposeDelegate = self; 

    [mailer setSubject:[NSString stringWithFormat:@"Appointment From Mr/Mrs. %@",text1.text]]; 

    NSArray *toRecipients = [NSArray arrayWithObjects:@"[email protected]", nil]; 
    [mailer setToRecipients:toRecipients]; 



    NSString *emailBody =[NSString stringWithFormat:@"Name :%@\nDate: %@\nPreferred Time Slot: %@\nE-Mail:%@\nSpecific Requests:",text1.text,text2.text,text3.text,text4.text,text5.text]; 

    [mailer setMessageBody:emailBody isHTML:NO]; 


    [self presentModalViewController:mailer animated:YES]; 

    [mailer release]; 
} 

我現在面臨的問題是,所有的四個文本字段值只顯示第五文本字段值不displayed..Any想法?......我失去了什麼? ..

回答

1

編輯下面的代碼行

NSString *emailBody =[NSString stringWithFormat:@"Name :%@\nDate: %@\nPreferred Time Slot: %@\nE-Mail:%@\nSpecific Requests:%@",text1.text,text2.text,text3.text,text4.text,text5.text]; 

你會得到你的要求......不要忘記使用resignFirstresponder隱藏鍵盤後你輸入文字...

+0

感謝您的答案和額外的信息..我想問在其他一些問題... – Dany 2012-07-11 09:52:23

2

您只有四個%@字符串形式,因此提供給format方法的最後一個參數將被忽略。

更改格式字符串有五個參數:

NSString *emailBody =[NSString stringWithFormat:@"Name :%@\nDate: %@\nPreferred Time Slot: %@\nE-Mail:%@\nSpecific Requests:%2",text1.text,text2.text,text3.text,text4.text,text5.text];