Filipe Louro
Filipe Louro

Reputation: 87

Dismissing and Presenting MFMessageComposeViewController

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;

Upvotes: 3

Views: 812

Answers (1)

Mirko Brunner
Mirko Brunner

Reputation: 2215

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

 messageViewController.dismissViewControllerAnimated(true, nil);

Upvotes: 1

Related Questions