1

I've got a MFMailComposeViewController and I believe it is implemented correctly. However when it is displayed on the screen (through modal) it just opens, hangs for a second, then closes and logs MFMailComposeResultCancelled

any thoughts?

            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 found these in the log

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

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

James Dunay
  • 2,714
  • 8
  • 41
  • 66
  • Are you trying to present more than 1 view controller at the same time? – Nekak Kinich Oct 29 '13 at 17:17
  • I dont feel like i am, but the `Unbalanced Calls` seems to speak otherwise – James Dunay Oct 29 '13 at 17:22
  • Check this post: [Unbalanced calls to begin/end appearance transitions for ](http://stackoverflow.com/questions/14412890/unbalanced-calls-to-begin-end-appearance-transitions-for-uinavigationcontroller) – Nekak Kinich Oct 29 '13 at 17:22
  • Yea took a look at that though setting the animation to nil didnt work. it still calls `MFMailComposeResultCancelled` and dismisses itself – James Dunay Oct 29 '13 at 17:51
  • Where is this code getting called from? What is the object represented by `self`? Perhaps that object is being released. – ChrisH Oct 29 '13 at 18:41
  • @ChrisH So the object that it's being called from is a UITableviewcontroller. and it is being called when `didselectItemAtIndexPath` is run. – James Dunay Oct 29 '13 at 20:43
  • Also i noticed one thing that stood out, the right Navigation button item is disabled. Not sure if that has anything to do with it. But also where i set `setToRecipients:` that actually isnt placed into the recipents field. even if i enter an actual email with '@' – James Dunay Oct 29 '13 at 20:45
  • Did you see this? http://stackoverflow.com/questions/18978864/cannot-show-modal-viewcontroller-in-ios7 – ChrisH Oct 29 '13 at 20:47

2 Answers2

3

MFMailComposeResultCancelled is called if you have any changes that occur to the UI when the MFMailComposer is pulled up.

I must be the default iOS Navigation header, though you can change the tint.

James Dunay
  • 2,714
  • 8
  • 41
  • 66
0

On your completion if you don't do anything, put nil, probably this is the problem.

Nekak Kinich
  • 905
  • 7
  • 10