0

The Problem - Preparing and showing an MFMessageComposeViewController is trivial as per the Apple docs. What I need to know is when this has been fully presented.


Explanation - Showing the MFMessageViewComposeController with a completion block is easy, but doesn't solve my problem:

[self presentViewController:messageController animated:YES completion:^(void){

    //Controller has been shown. But not really....

}];

The problem is more obvious for messages to larger groups of recipients (say 50 people). The completion block gets called, but the phone's screen remains black. Several seconds later, the messaging window appears. Several seconds later, the recipient list becomes active with a flashing cursor. Basically, there's a lot of loading and processing that goes on after the controller has supposedly been presented.


What I'd like - To figure out when the interface has been fully loaded. I don't expect a simple answer, and I've already spent quite a bit of time on it - definitely bounty worthy. If you can post a working answer with code I'll award maximum bounty for it.

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Jordan Smith
  • 10,310
  • 7
  • 68
  • 114

1 Answers1

0

Just check MFMailComposeViewController view's frame. Once it achieves top of the screen handle the appearance.

[self presentViewController:messageController animated:YES completion:^
{
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^
    {
        while(messageController.view.frame.origin.y > 0)
        {
        }

        dispatch_async(dispatch_get_main_queue(), ^
        {
            // Handle appearance of MFMailComposeViewController
        });
    });
}];

The other way is to wait 0.3 seconds using dispatch_after() method. But this time interval could be changed next versions of iOS.

Igor Matyushkin
  • 778
  • 4
  • 4
  • Thanks! Unfortunately, the frame origin is actually 0 here anyway. After the frame's origin gets to zero there's still a bit more loading that goes on, including a screen that goes black, and a text view that takes several seconds to become active - so doing this doesn't help. – Jordan Smith Mar 28 '14 at 11:37