Elias Rahme
Elias Rahme

Reputation: 2227

Resize the MFMailComposeViewController and prevent it from covering the whole screen

I have a MFMailComposeViewController, and it's called using this method:

    - (IBAction)sendEmail:(id)sender {

    NSArray *toRecipents = [NSArray arrayWithObject:@"[email protected]"];

    MFMailComposeViewController *mc = [[MFMailComposeViewController alloc] init];
    mc.mailComposeDelegate = self;
    [mc setSubject:@"Email"];
    [mc setMessageBody:message.text isHTML:NO];
    [mc setToRecipients:toRecipents];

    // Present mail view controller on screen
    [self presentViewController:mc animated:YES completion:NULL];

}

I want when the controller loads up , I want his height to be 50 pixels less than the view's height, I don't want him to take the whole screen. Is there any way to do so?.

EDIT: The problem I'm facing is, this MFMailComposeViewController I'm calling , is initially inside a view controller that was called using a modal page curl effect, so the curl effect is preventing me to push the send email button! this is a pic

enter image description here

So no matter how much u try, u just can't click the send button…what can i do in this situation without getting rejected by apple

EDIT 2: Can i just close the modal curl page effect and then pop up this view controller?

Upvotes: 0

Views: 610

Answers (2)

Barbara R
Barbara R

Reputation: 1057

As far as I know, there if no standard or allowed way to do what you want.
Also I would be concerned about passing approval since Apple indicates the following regarding mail composer:

Important: The view hierarchy of this class is private and you must not modify it. You can, however, customize the appearance of an instance by using the UIAppearance protocol. After presenting a mail comopose view controller, your app cannot change the email content. The user can edit the content of a presented instance but the system ignores programmatic changes. If you want to set values for the content fields, do so before presenting the interface. class reference

If you've some custom design requirements for sending emails I'd recommend implementing your own views and using some server to send email, but I'm not sure how hard are your design requirements.

Upvotes: 1

Vlad Papko
Vlad Papko

Reputation: 13302

Try to change frame of MFMailComposeViewController manually and use addSubview: instead of presentViewController:animated:completion::

mc.view.frame = CGRectMake(0, 20, 320, 400);
// Use addSubview: insead of [self presentViewController:mc animated:YES completion:NULL];
[self.view addSubview:mc.view];

enter image description here

Notice: I am not sure this this behaviour would be passed through Apple App Store approval process.

Upvotes: 0

Related Questions