Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dismissing and Presenting MFMessageComposeViewController

Tags:

ios

swift

I am keeping a variable holding the MFMessageComposeViewController instance. If I click "cancel" in the SMS view, I dismiss the MFMessageComposeViewController.

Now if I try to present it again, the view loads but the keyboard is not visible and the view is like in read-only mode. I tried to instantiate again the variable that I have for the MFMessageComposeViewController. What happens then is that I the view loads correctly, but the keyboard does not show like in the first time I present the view.

Can you help in what am I doing wrong?

Here is how I present the view:

messageViewController.body = message;
messageViewController.recipients = [userDefaults.stringForKey("MessageNumber")!];
messageViewController.messageComposeDelegate = self;
self.presentViewController(messageViewController, animated: true, completion: nil);

and how I dismiss it:

case MessageComposeResultCancelled.value:
self.dismissViewControllerAnimated(true, nil);
//messageViewController = MFMessageComposeViewController();
break;
like image 430
Filipe Louro Avatar asked May 20 '26 03:05

Filipe Louro


1 Answers

The MessageController must call the method dismissViewControllerAnimated() not your parent ViewController.

 messageViewController.dismissViewControllerAnimated(true, nil);
like image 65
Mirko Brunner Avatar answered May 21 '26 15:05

Mirko Brunner



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!