不显示UITextField内容的MessageUI框架问题



我在发送邮件的应用程序中包含了messageUI框架。它包含五个UITextField,用户输入的值应显示在邮件正文中。这是我的代码

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:@"info@xxx.com", 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];
}

我面临的问题是,所有四个文本字段值都显示了,只有第五个文本字段的值没有显示。。知道吗?。。。我错过什么了吗?。。。

在字符串的形式中只有四个%@,因此提供给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]; 

编辑以下代码行

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

你会得到你的要求。。。不要忘记在你输入文本后使用辞职第一响应程序隐藏键盘。。。

最新更新