Alan
Alan

Reputation: 9471

Modal View's toolbar is obscured. MFMailComposeViewController

I am trying to bring up an Email Window in my application, however the top toolbar that is suppose to have Cancel and Send is being obscured by the navigation controller.

I believe the reason is that I am calling

 if ([MFMailComposeViewController canSendMail]) {
            MFMailComposeViewController* controller = [[MFMailComposeViewController alloc] init];
            controller.mailComposeDelegate = self;
            [controller setToRecipients:[NSArray arrayWithObject:@"[email protected]"]];
            [controller setSubject:@"Mobile HelpDesk App"];
            [controller setMessageBody:@"" isHTML:NO];
            if (controller){
                [self presentViewController:controller animated:YES completion:^{}];
            }

        }

From a child ViewController that controls a view inside a scrollview (For Paging).

How do I get the toolbar to be on top of the navigation bar? Right now, it's only showing the new email window, but I cannot cancel or send the email.

I tried using [self.parentViewController presentViewController:controller animated:YES completion:^{}];, but that didn't do anything.

Thanks!

Upvotes: 0

Views: 271

Answers (2)

csundman
csundman

Reputation: 1751

This sounds like it could be as simple as changing:

 [self presentViewController:controller animated:YES completion:^{}];

to

 [self.navigationController presentViewController:controller animated:YES completion:^{}];

Hope this helps you.

Upvotes: 0

Wain
Wain

Reputation: 119031

You can't use presentViewController:... from a view controller whose view isn't at the top of the view hierarchy (and so most likely doesn't occupy the whole screen). As you've seen, this results in a presented view which is perhaps partially visible and perhaps doesn't respond to touches in some areas.

Trying self.parentViewController is the correct solution (though the code you show is invalid). You need to ensure that you navigate far enough up the hierarchy to get to the 'root' view controller and present from there.

Upvotes: 1

Related Questions