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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:19:37+00:00 2026-05-26T02:19:37+00:00

The question deals with an application which uses many views in a UINavigation controller

  • 0

The question deals with an application which uses many views in a UINavigation controller Style.

I have a simple function in my delegate which can be used by all views to plot-out error message

// In Appdelegate.m

-(void)popErrorWindow:(NSString *)theError
{
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:theError
                                                   delegate:self cancelButtonTitle:@"OK" otherButtonTitles:@"Report",nil];
    [alert show];
    [alert release];
}


- (void)alertView:(UIAlertView *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
        if (buttonIndex == 1)
        {
            NSLog(@"report");
            [self mailIt:@"error name"];
        }
    }

Now, wanting to have a mechanism that will email the error along with some other data I have created this:

-(void)mailIt:(NSString *)theError {
    NSLog(@"Mail it");
    pickerMail = [[MFMailComposeViewController alloc] init];
    pickerMail.mailComposeDelegate = self;

    [pickerMail setSubject:@"error via email"];

NSMutableString *body = [NSMutableString string];

    [body appendString:@"Error XXX "];

    [pickerMail setMessageBody:body isHTML:YES];


    // Problem here:
    [self.window presentModalViewController:pickerMail animated:YES];   
}

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

{
    // Problem here:
    [self.window  dismissModalViewControllerAnimated:YES];
    //NSLog(@"mail was sent");
}

The problem is in self.window , which is not the right way to access this from the delegate,
I still want to have the mail element in the delegate as all views can call the error alert, and I would like to have only one place for this mechanism.

How should I do it from inside the delegate, what should replace the self.window?

  • 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-26T02:19:38+00:00Added an answer on May 26, 2026 at 2:19 am
    - (void)mailComposeController:(MFMailComposeViewController *)controller 
              didFinishWithResult:(MFMailComposeResult)result
                            error:(NSError *)error
    {
        [controller dismissModalViewControllerAnimated:YES];
    }
    

    EDIT :

    The - (void)presentModalViewController:(UIViewController *)vc and - (void)dismissModalViewControllerAnimated:(BOOL)animated methods are an UIViewController instance method, so you cannot use it with an UIWindow.

    In order to present your mail controller with a nice animation, you can do that :

    UIViewController *aController = self.navigationController.presentedViewController;
    [aController presentModalViewController:pickerMail animated:YES];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The question deals with an application which uses many views in a UINavigation controller
How can I specify which adaptor to begin listening on? I have an application
I have a question for which I suspect the answer is a bit complex.
I want to develop an Android application which can run on all ,screen type
I have a function in C that accepts and returns a double (and uses
This question deals mainly with streams in web application in .net. In my webapplication
I have an application that deals with data in the following structure: struct Message
I am developing an application in which it deals with reading data from excel
My original question: I'm creating a simple drawing application and need to be able
I have an application which needs to get intraday stock quotes on several assets

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.