문제

I have a menu loaded from a tableview using the modal curl page effect. So once the user hit's a certain button, this effect will show up. When the user hits the contact us button, an email compose will show up, but since it's a modal curl effect, the send and cancel button are hidden.
I am pretty aware that apple will reject the app if any size changing has been done, so i am looking for an alternative : close current modal effect, and push a new MFMailComposeView. How can i do that?

EDIT : CODE SO FAR

- (IBAction)sendEmail:(id)sender {

    // Email Subject
  //  NSString *emailTitle = @"Test Email";
    // Email Content
  //  NSString *messageBody = @"iOS programming is so fun!";
    // To address
    NSArray *toRecipents = [NSArray arrayWithObject:@"eli@gmail.com"];

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

    //    self.view.superview.bounds = CGRectMake(0, 0, self.view.bounds.size.width, 200);

    // Present mail view controller on screen
    [self presentViewController:mc animated:YES completion:NULL];
    //[self dismissViewControllerAnimated:YES completion:nil];
}
도움이 되었습니까?

해결책

I figured it out , it's a bit a handful but its worth it.
First of all, at the ViewController where the action of sending an email should be called, put an NSNotification, like this :

[self dismissViewControllerAnimated:YES completion:^{

[[NSNotificationCenter defaultCenter] postNotificationName:@"email" object:nil];

}];

Later on, when that view disappears, an original view controller will show up, since it was called through a modal view controller, in that one put :

-(void)createEmail{


  MFMailComposeViewController *  mc = [[MFMailComposeViewController alloc] init];
    NSArray *toRecipents = [NSArray arrayWithObject:@"elias@gmail.com"];
    mc.mailComposeDelegate = self;
    [mc setSubject:_emailSubject];
    [mc setMessageBody:_emailMessage isHTML:NO];
    [mc setToRecipients:toRecipents];

    [self presentViewController:mc animated:YES completion:nil];

}

And, in the viewDidload, add the following line :

[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(createEmail)
                                             name:@"email" object:nil];

That way, we are telling the original view controller, in her did load phase, to listen for a notification called email, and when we call it in the Email view controller, the app will know that a triggered notification has been fired, and will search for her following action, which is the delegate of the MFMailComposeViewController.
That way, for any future developer, you will accomplish the designated target

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top