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 7166771
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:28:01+00:00 2026-05-28T14:28:01+00:00

I have been searching for a solution to my problem but haven’t found anything

  • 0

I have been searching for a solution to my problem but haven’t found anything so far.

I have a UINavigationController with a stack of UIViewControllers (this is all within a TabbarController, if that is relevant). At the last ViewController, I want to send an email:

MFMailComposeViewController *emailVC = [[MFMailComposeViewController alloc] init];
// fill out emailVC properties ...
[self presentModalViewController:emailVC animated:YES];

Then in the delegate after the email has been sent, I want to close the email viewcontroller and also pop off the last viewcontroller in the NavigationController stack:

-(void)mailComposeController:(MFMailComposeViewController *)controller
      didFinishWithResult:(MFMailComposeResult)result
                    error:(NSError *)error
    {
        // save some variables here ...
        [self dismissModalViewControllerAnimated:YES]; // This line works by itself
        [self.navigationController popViewControllerAnimated:NO]; // this line causes EXC_BAD_ACCESS

However, the last line causes a crash somewhere.
I have checked the ViewController stack before and after. The last viewController correctly gets removed from the list.

Any thoughts or suggestions are welcome. The problem could lie somewhere else in my code I want to make sure I have this part ok. Thank you.

  • 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-05-28T14:28:02+00:00Added an answer on May 28, 2026 at 2:28 pm

    Try initiating the pop delayed

    iOS 3 and later solution

    -(void)mailComposeController:(MFMailComposeViewController *)controller
          didFinishWithResult:(MFMailComposeResult)result
                        error:(NSError *)error
    {
        [...]
        [self dismissModalViewControllerAnimated:YES];
        [self performSelector:@selector(doThePop) withObject:nil afterDelay:0.40];
        [...]
    }
    
    - (void)doThePop
    {
        [self.navigationController popViewControllerAnimated:NO];
    }
    

    You may want to fine-tune the delay.

    iOS 5 and later solution

    -(void)mailComposeController:(MFMailComposeViewController *)controller
              didFinishWithResult:(MFMailComposeResult)result
                            error:(NSError *)error
    {
        [...]
        [self dismissViewControllerAnimated:YES completion:^
        {
            [self.navigationController popViewControllerAnimated:NO];
        }];
        [...]
    }
    

    Even though this seems a bit hackish, it should work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi I have been searching a solution to this problem for many days but
I have been searching in a lot of topics but I haven't found anything
I've been searching for a solution to this problem endlessly and thus far, haven't
So I have been searching everywhere for a solution to this problem. I have
I have been searching everywhere but can't seem to find a solution to this
I've been searching a lot for this problem and I can't find a solution.
I've been searching for a solution to this problem for a few days now
I have been searching and cant find a consistent solution to my problem :
I have been searching for info on this to no avail. The context of
I have been searching forever. Sorry, I am pretty desperate at this point so

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.