MFMessageComposeViewController first alloc takes seconds
-
14-11-2019 - |
Question
I am trying to show an MFMessageComposeViewController with the following code:
controller = [[MFMessageComposeViewController alloc] init];
if([MFMessageComposeViewController canSendText])
{
controller.body = [NSString stringWithFormat:@"%@%@%@", itemString, amountString, callTimeString];
controller.recipients = [NSArray arrayWithObject:@"12345678"];
controller.messageComposeDelegate = self;
[self presentModalViewController:controller animated:YES];
}
The problem is when I press the button to bring up the MFMessageComposeViewController, the alloc takes a few seconds. I have tried moving the alloc line to my viewDidLoad method, however this just moves the problem and I end up waiting a few seconds for the view to load.
Is there any method to speed up the alloc and showing of my MFMessageComposeViewController or use a delegate method or something?
Thanks.
Solution
Well, what you are doing seems about right. You are not doing anything wrong. Check this - Can't set recipients of MFMessageComposeViewController? & the link attached in the answer
OTHER TIPS
I had a similar problem, check out my answer here: I need a callback when MFMessegeComposeViewController finally loads
For me it wasn't the alloc taking too long, it was the presentModalViewController
of the MFMessageComposeViewController
, which blocks on Apple's code on the UI thread, so no way to background it except for throwing up your own progress view.