0

After spending some time looking at similar questions on stack overflow, unfortunately none seemed to resolve my issue.

I'm using a UIActionSheet, when the user clicks send email on the action sheet, the following code is called:

if ([MFMailComposeViewController   canSendMail]){
                NSString *emailTitle = @"bla bla bla";
                // Email Content
                NSString *messageBody = @"bla bla bla";
                // To address
                NSArray *toRecipents = [NSArray arrayWithObject:@"test@test.com"];

                MFMailComposeViewController *mc = [[MFMailComposeViewController alloc] init];
                mc.mailComposeDelegate = self;
                [mc setSubject:emailTitle];
                [mc setMessageBody:messageBody isHTML:NO];
                [mc setToRecipients:toRecipents];


                [self.view.window.rootViewController presentViewController:mc animated:YES completion:NULL];
                NSLog(@"email view opened");
            }
                else{
                    UIAlertView *anAlert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"No mail account setup on device" delegate:self cancelButtonTitle:nil otherButtonTitles:nil];
                    [anAlert addButtonWithTitle:@"Cancel"];
                    [anAlert show];
                }

MFMailComposeViewController opens on my iPhone in portrait mode, but when opening the app in landscape mode on an iPad, nothing happens. No view pops up, nothing at all. It shows "email view opened" in the NSLog but nothing else. Thoughts?

Edit The app is portrait ONLY on iPhone, and any orientation for iPad

EDIT AGAIN After playing around a bit more, if I assign the code to a button, it works fine, only when selecting email from the action sheet is this problem present

Manesh
  • 528
  • 6
  • 20
  • possible duplicate of [Modal View Controller Won't Start in Landscape Mode](http://stackoverflow.com/questions/3772016/modal-view-controller-wont-start-in-landscape-mode) – LoVo Mar 13 '15 at 10:41
  • Did you try to use the root view controller to present it? – Dennis Mar 13 '15 at 10:44
  • @Dennis I've tried this using but no difference was made `[self.view.window.rootViewController presentViewController:mc animated:YES completion:NULL];` – Manesh Mar 13 '15 at 10:49
  • I've looked at those also and It remains unsolved sorry @LoVo – Manesh Mar 13 '15 at 11:20

1 Answers1

0

Found the answer, this is it :

dispatch_async(dispatch_get_main_queue(), ^ {
    // INSERT EMAIL CODE HERE
});
Manesh
  • 528
  • 6
  • 20