Stan Pak
Stan Pak

Reputation: 119

How can I get the view of MFMailComposeViewController's message body?

I need to set the sizes of the view of MFMailComposeViewController's message body. How can I get the view?

The following is the code of creating the email sender.

MFMailComposeViewController* controller = [[MFMailComposeViewController alloc] init];
controller.mailComposeDelegate = self;
[controller setSubject:titleForEmail];
[controller setMessageBody:textForEmail isHTML:isHtml];     
[parentController presentModalViewController:controller animated:YES];
[controller release];

Upvotes: 1

Views: 1801

Answers (2)

Bob Spryn
Bob Spryn

Reputation: 17812

You may get rejected for this, but its not using any API's but looping through subviews. I'm attempting it.

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

    for (UIView *subview in [controller.view subviews]) {
        for (UIView *myview in [subview subviews]) {
            for (UIView *theview in [myview subviews]) {
                if ([NSStringFromClass([theview class]) isEqualToString:@"MFMailComposeView"]) {
                    for (UIView *aview in [theview subviews]) {
                        for (UIView *thisview in [aview subviews]) {
                            if ([NSStringFromClass([thisview class]) isEqualToString:@"MFComposeScrollView"]) {
                                for (UIView *bview in [thisview subviews]) {
                                    if ([NSStringFromClass([bview class]) isEqualToString:@"MFComposeTextContentView"]) {
                                        NSLog(@"%@", ((UITextView *)bview).text);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}

UPDATE

This is broken in iOS6. Trying to find a workaround.

Upvotes: 6

Anomie
Anomie

Reputation: 94834

You don't. Quoth the documentation:

Important: The mail composition interface itself is not customizable and must not be modified by your application.

If you do mess with it and the reviewers notice, Apple will reject your application.

Upvotes: 4

Related Questions