【问题标题】:MFMailComposeViewController Opens then closesMFMailComposeViewController 打开然后关闭
【发布时间】:2024-05-22 04:30:01
【问题描述】:

我有一个 MFMailComposeViewController,我相信它实现正确。但是,当它显示在屏幕上时(通过模式),​​它只是打开,挂起一秒钟,然后关闭并记录 MFMailComposeResultCancelled

有什么想法吗?

            if ([MFMailComposeViewController canSendMail]){
                MFMailComposeViewController *composer = [[MFMailComposeViewController alloc] init];



                if( composer == nil ){
                    UIAlertView* alert_view = [[UIAlertView alloc] initWithTitle:@"message"
                                                                          message:@"You will need to setup a mail account on your device before you can send mail!"
                                                                         delegate:nil
                                                                cancelButtonTitle:@"OK"
                                                                otherButtonTitles:nil];
                    [alert_view show];
                    return;
                }else{



                composer.mailComposeDelegate = self;
                [composer setSubject:@"I have an issue"];
                [composer setMessageBody:@"" isHTML:NO];
                [composer setToRecipients:@[@"email"]];
                }


                [self presentViewController:composer animated:YES completion:^{
                    ;
                }];

EDIT 在日志中发现了这些

Unbalanced calls to begin/end appearance transitions for <UINavigationController: 0xcda5e90>.

The operation couldn’t be completed. (Cocoa error 4097.)

【问题讨论】:

  • 您是否要同时呈现多个视图控制器?
  • 我不觉得我是,但Unbalanced Calls 似乎不这样说
  • 是的,虽然将动画设置为 nil 没有用,但还是看了一下。它仍然调用MFMailComposeResultCancelled 并自行关闭
  • 这段代码是从哪里调用的? self代表的对象是什么?也许该对象正在被释放。

标签: ios iphone objective-c xcode ios7


【解决方案1】:

如果在拉起 MFMailComposer 时 UI 发生任何更改,则会调用 MFMailComposeResultCancelled。

我必须是默认的 iOS 导航标题,但您可以更改色调。

【讨论】:

    【解决方案2】:

    如果你什么都不做,完成后,输入nil,可能就是这个问题。

    【讨论】:

    • 仍然遇到问题,尽管在日志中我得到了更多信息,请在上面发布
    • 好的,请给我们日志:)