简体   繁体   中英

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@email.com"];

    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

在此处输入图片说明

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?

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.

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];

在此处输入图片说明

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM