在 MFMessageComposeViewController 中点击取消后没有任何反应

发布于 2024-12-12 05:43:54 字数 446 浏览 0 评论 0原文

尽管在使用 MFMailComposeViewController 后,可以直接转移到 MFMessageComposeViewController ,但有一个问题。

假设这段代码:

MFMessageComposeViewController* mySMS = [[MFMessageComposeViewController alloc] init];
[mySMS setDelegate:self];
[self presentModalViewController:mySMS animated:YES];

对于邮件来说,它是这样工作的,但是在短信中,您应该将不同的委托设置为这样的内部结构:

[SMS setMessageComposeDelegate:self];

希望您不会像我今天早些时候所做的那样陷入困境。

After though that after using MFMailComposeViewController the move to MFMessageComposeViewController was straight foward, but there is a catch.

Suppose this code:

MFMessageComposeViewController* mySMS = [[MFMessageComposeViewController alloc] init];
[mySMS setDelegate:self];
[self presentModalViewController:mySMS animated:YES];

It works this way for mails, but in sms you should set different the delegate to an internal structure like this:

[SMS setMessageComposeDelegate:self];

Hope you don not get stuck on this as I did early today.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

莳間冲淡了誓言ζ 2024-12-19 05:43:54

您需要实现委托方法 -(void)mailComposeController(MFMailComposeViewController*)controller didFinishWithResult (MFMailComposeResult)result error:(NSError*)error:

在其中您应该自己关闭它:

-(void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error 
{
    [self dismissModalViewControllerAnimated:YES]; 
}

You need to Implement the delegate method -(void)mailComposeController(MFMailComposeViewController*)controller didFinishWithResult (MFMailComposeResult)result error:(NSError*)error:

And inside it you should dismiss it yourself:

-(void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error 
{
    [self dismissModalViewControllerAnimated:YES]; 
}
把回忆走一遍 2024-12-19 05:43:54

您可以在 Apple 文档中看到 MFMailComposeResult

  enum MFMailComposeResult {
    MFMailComposeResultCancelled,
    MFMailComposeResultSaved,
    MFMailComposeResultSent,
    MFMailComposeResultFailed
 };
 typedef enum MFMailComposeResult MFMailComposeResult; 

并且您必须在委托方法中自行关闭控制器

 - (void) mailComposeController:(MFMailComposeViewController *)controller          didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error
 {
  switch (result){
    case MFMailComposeResultCancelled:
        NSLog(@"Mail cancelled");
        break;
    case MFMailComposeResultSaved:
        NSLog(@"Mail saved");
        break;
    case MFMailComposeResultSent:
        NSLog(@"Mail sent");
        break;
    case MFMailComposeResultFailed:
        NSLog(@"Mail sent failure: %@", [error localizedDescription]);
        break;
    default:
        break;
   }
// Close the Mail Interface
   [self dismissViewControllerAnimated:YES completion:NULL];
}

You can see MFMailComposeResult in Apple documentation

  enum MFMailComposeResult {
    MFMailComposeResultCancelled,
    MFMailComposeResultSaved,
    MFMailComposeResultSent,
    MFMailComposeResultFailed
 };
 typedef enum MFMailComposeResult MFMailComposeResult; 

And you must dismiss controller by yourself in delegate method

 - (void) mailComposeController:(MFMailComposeViewController *)controller          didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error
 {
  switch (result){
    case MFMailComposeResultCancelled:
        NSLog(@"Mail cancelled");
        break;
    case MFMailComposeResultSaved:
        NSLog(@"Mail saved");
        break;
    case MFMailComposeResultSent:
        NSLog(@"Mail sent");
        break;
    case MFMailComposeResultFailed:
        NSLog(@"Mail sent failure: %@", [error localizedDescription]);
        break;
    default:
        break;
   }
// Close the Mail Interface
   [self dismissViewControllerAnimated:YES completion:NULL];
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文