在我的电子邮件作曲家中,我希望'cancelbuttonclicked' 的结果来关闭 MFMailComposerViewController。我可以在 switch 语句中实现还是需要单独的方法。另外,我希望发送按钮在关闭之前发送消息。
- (void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error {
switch (result) {
case MFMailComposeResultSent:{
UIAlertView *messageSent = [[UIAlertView alloc] initWithTitle:@"Message Sent" message:@"Your message has been sent" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[messageSent show];
break;
}
case MFMailComposeResultSaved:{
UIAlertView *messageComposeResultSaved = [[UIAlertView alloc] initWithTitle:@"Message Saved" message:@"Your message has been saved" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[messageComposeResultSaved show];
break;
}
case MFMailComposeResultCancelled:{
UIAlertView *messageComposeResultCancelled = [[UIAlertView alloc] initWithTitle:@"Message Cancelled" message:@"Your message has been cancelled" delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil];
[messageComposeResultCancelled show];
break;}
case MFMailComposeResultFailed:{
UIAlertView *messageFailed = [[UIAlertView alloc]initWithTitle:@"Message Failed" message:@"Your message could not be sent" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[messageFailed show];
break;
}
}
}