Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7939367
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T23:04:45+00:00 2026-06-03T23:04:45+00:00

I am opening an email sheet to send a file. It works great except

  • 0

I am opening an email sheet to send a file. It works great except that I can’t go back to my app.

When I hit cancel button, it ask if to delete or save draft, and stay there. It doesn’t go back to app page.

code:

//send email log-------------------------
    NSLog(@"mail");
    [[CCDirector sharedDirector] pause];

    picker = [[MFMailComposeViewController alloc] init];
    picker.mailComposeDelegate = self;

    //Fill in the email as you see fit
    NSArray *toRecipients = [NSArray arrayWithObject:@"name@gmail.com"]; 
    [picker setToRecipients:toRecipients];


    NSArray *paths2 = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *dataPath = [[paths2 objectAtIndex:0] stringByAppendingPathComponent:@"Test.txt"];
    NSData *data = [NSData dataWithContentsOfFile:dataPath];
    [picker addAttachmentData:data mimeType:@"text/txt" fileName:@"Test.txt"];

    NSString *emailBody = @"Test   ";
    [picker setMessageBody:emailBody isHTML:NO];
    [picker setSubject:@"hardware test ##   "];

    //display the view
    [[[CCDirector sharedDirector] openGLView] addSubview:picker.view];
    [[CCDirector sharedDirector] stopAnimation]; 

EDIT:

I have added the function suggested in the answer right here, he calls the function when I hit cancel, but it stays in that sheet.
I have to say that I am using a cclayer (cocos2d) so the layer is defined with :

@interface HelloWorldLayer : CCLayer< MFMailComposeViewControllerDelegate>

Any other suggestion ?

Thanks a lot.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T23:04:47+00:00Added an answer on June 3, 2026 at 11:04 pm

    You have to implement the delegate method

    - (void)mailComposeController:(MFMailComposeViewController*)controller
            didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
    

    and dismiss the view controller in there:

    [picker dismissViewControllerAnimated:YES completion:^{}];
    

    UPDATE:

    - (void)mailComposeController:(MFMailComposeViewController*)controller
                didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error {
        [picker dismissViewControllerAnimated:YES completion:^{}];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can an app send an email without opening the email interface? How?
I have an Android app that should open links sent via email. I only
I am trying to create a link that can be sent via email which
Opening an XML file in Internet explorer gives a security warning. IE has a
Opening an application( probably an .exe file) as an administrator in headless mode from
After opening a file created by root in vim , how to change the
I am having problems opening an existing Excel file with Tcl Tk. I am
I found that some application, like GoodReader or Docs to Go, once installed can
In WPF I have one window opening a second window that allows some data
when I try to attach a file to an email, I get a java.io.FileNotFoundException:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.