Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xcode 两个不同的MFMailComposeViewController相同的视图_Xcode_Email - Fatal编程技术网

Xcode 两个不同的MFMailComposeViewController相同的视图

Xcode 两个不同的MFMailComposeViewController相同的视图,xcode,email,Xcode,Email,嗨,我有两个不同的MFMailComposeViewController相同的视图,它们在两个不同的邮件地址写入,我需要分别设置一个不同的成功警报。我尝试使用tag,但MFMailComposeViewController无法使用tag 我怎么能做到 这是我的第二个MFMailComposeViewController -(IBAction)inviaMail2{ MFMailComposeViewController *mail2 = [[MFMailComposeViewController

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

我怎么能做到

这是我的第二个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];
}
}
更新: 不知何故,我错过了您可以访问控制器的功能。查看.tag,它更接近OP想要的功能。
我将保留我的通用答案,因为它可能适用于您没有自定义字段可以使用的其他情况

原始答案: 这更多的是针对这个问题的通用设计解决方案(解决方案?)。 我不确定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) { ... }
}

请小心设置视图的标记。我是在iOS 5上这样做的,它不允许您设置主题或消息正文。可能是iOS 5错误,因为这在iOS 6上不是问题。