Search code examples
iosobjective-ccore-animationmfmailcomposeviewcontroller

MFMailComposeViewController Resets Other View Frames


When you click a "contact" button in my app, a number of views are animated to slide the initial views out and the contact views in. One of the options at that point is to send and email. When you tap that button, I use MFMailComposeViewController to show the in-app email view.

The Issue:

As the email view animates in, the display reverts back to almost the initial view. The views in which I animated their frame, are reset to their original locations, but the one view I fade out stays faded out.

I am fairly certain I am not doing anything out of the ordinary with the animations and the mail composer code is exactly the same as all the references I have found.

EDIT:

Here is my animation code. I am basically animate a couple views off the screen and a couple others on the screen. Everything is layed out in a single view controller on a storyboard.

[UIView animateWithDuration:0.5f animations:^{
    searchView.frame = CGRectMake(0, originalSearchY - searchView.frame.size.height, searchView.frame.size.width, searchView.frame.size.height);
    footerView.frame = CGRectMake(0, originalFooterY + footerView.frame.size.height, footerView.frame.size.width, footerView.frame.size.height);
    refreshView.alpha = 0;
} completion:^(BOOL finished) {
    [UIView animateWithDuration:0.5f animations:^{
        supportView.frame = CGRectMake(0, 64, supportView.frame.size.width, supportView.frame.size.height);
        closeView.frame = CGRectMake(0, originalCloseY - closeView.frame.size.height, closeView.frame.size.width, closeView.frame.size.height);
    } completion:^(BOOL finished) {}];
}];

Here is a screen flow of whats happening for clarification...

screen flow

  1. Tap the contact button, animated to the contact screen
  2. Tap on the email button, email composer is shown
  3. Cancel or send email
  4. As you can see the visibility is reverted back to screen 1, with "update data" view gone (this is the view I fade out rather than animate the frame)

Solution

  • Ok, so I finally figured out the issue. I was doing some initialization in - (void)viewDidLayoutSubviews and that is called as the modal email view appears and as it is dismissed. I ended up adding a boolean "isInitialized" variable and tweaking the view processing based on that.