1

嗨,我有两个不同的 MFMailComposeViewController 相同的视图,它们写在两个不同的邮件地址,我需要分别设置一个不同的成功警报。我尝试使用标签,但 MFMailComposeViewController 不能使用标签?

我怎么能这样做?

那是我的第二个 MFMailComposeViewController

-(IBAction)inviaMail2{
MFMailComposeViewController *mail2 = [[MFMailComposeViewController alloc] init];
mail2.mailComposeDelegate = self;

if([MFMailComposeViewController canSendMail]){
    [mail2 setToRecipients:[NSArray arrayWithObjects:@"piccolericette@alternativeindustries.it", nil]];
    [self presentModalViewController:mail2 animated:YES];

}
[mail2 release];
 }

 - (void)mailComposeController2:(MFMailComposeViewController *)controller2 didFinishWithResult:(MFMailComposeResult)result2 error:(NSError *)error{

[self dismissModalViewControllerAnimated:YES];

if (result2 == MFMailComposeResultFailed){
    UIAlertView *alert2 = [[UIAlertView alloc] initWithTitle:@"Messaggio non inviato." message:@"Non è stato possibile inviare la tua mail, verifica la tua connessione internet e riprova." delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil];
    [alert2 show];
    [alert2 release];
}
else {
    UIAlertView *alert2 = [[UIAlertView alloc] initWithTitle:@"Messaggio inviato." message:@"Grazie per avermi contattato, ti risponderò il più presto possibile." delegate:self cancelButtonTitle:@"Prego" otherButtonTitles:nil];
    [alert2 show];
    [alert2 release];
}
}
4

1 回答 1

3

更新: 我不知何故错过了您可以访问控制器。查看更接近 OP 想要的 .tag。
我会保留我的通用答案,因为它可能适用于您没有可以使用的自定义字段的其他情况。

原始答案: 这更多是针对此问题的通用设计解决方案(解决方法?)。我不确定 MFMailComposeViewController 是否有任何可用于区分的动态用户信息字段,但您可以在类中定义 2 个 MFMailComposeViewController* 属性,在创建时分配给它们,并检查结果。

就像是:

@property (...) MFMailComposeViewController *mail1;
@property (...) MFMailComposeViewController *mail2;

self.mail1 = [[MFMailComposeViewController alloc] init];
...

 - (void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result2 error:(NSError *)error{
    if(controller == self.mail1) { ... }
}
于 2012-09-24T11:53:45.047 回答