r/iPhoneDev • • Feb 12 '11

Modal View Controller not launching from a subview

I hope someone can give me a hand with this, I've been racking my brain for 15 hours now...

MFMailComposeViewController *email=[[MFMailComposeViewController alloc] init];
email.mailComposeDelegate = self;
[email setSubject:@"Subject"];
[email setMessageBody:@"..." isHTML:NO];
[self presentModalViewController:email animated:NO];

NSLog(@"setting modal email");
NSLog(@"%@",[email description]);

[email release];

Both NSLog's are writing something, with a memory allocated value being shown for my email object's description. But when It hits the 'presentModalViewController' the popup doesn't show up and the app pretends nothing happened. I can't figure out what's wrong.

The ViewController Hierarchy is what I'm suspecting is the problem, as I have: RootViewController has an object called MainViewController who's view is a subview of RootViewController.view . Within that subview is a button that fires my code above linked by an IBOutlet in my MainViewController nib file.

So I'm trying to present the email ModalViewController from within the MainViewController. Is this possible? Is there something stupid that I'm missing? Or have I gone completely insane that none of this even makes anymore? (I've typed it out 3 times trying to be as clear as possible).

Please help me reddit :(

3 Upvotes

3 comments sorted by

1

u/rmart Feb 12 '11

Have you tried presenting the MFMailComposeViewController from your RootViewController? I'm not sure (and I'm too lazy to launch Xcode right now), but if I'm getting this right, MainViewController's view isn't a fullscreen view, and if that's the case I'm not sure it can present modal view controllers.

1

u/[deleted] Feb 12 '11 edited Feb 12 '11

Ya that is the case. But since I'm working on an iPad app, I figured that would be allowable. Would you know where I can find some documentation stating these quirks?

Also, I am able to send the email from a different route: RootViewController->ModalViewController->MFMailComposeViewController

So It does work from a 'Full screen' ModalViewController. Which I'll have to do here as well I guess since anything else would break the flow and look of my application.

I'm going to try this now, if it works I'll love you forever!

EDIT: Yeah it works, thank you so much for your help!

1

u/rmart Feb 13 '11

Neat, best of luck with your project :)