简体   繁体   中英

MFMessageComposeViewController does not show message body

I have implemented the send message from my app using MFMessageComposeViewController.

When the app loads the message view controller I get only the message recipient and a cancel button and no message body or Send button.

I do add the message recipient and message body before initializing the MFMessageComposeViewController.

Now when I touch on the recipient list, then Message body and Send button pops up.

Can I ensure that the message body and Send button shows up at the same time as Message recipients and the cancel button.

The code is as follows:

Button on click of which action is triggered.

@IBAction func sendMessage(sender: AnyObject) {
    if (self.canSendText()) {
        let messageComposeVC = self.configuredMessageComposeViewController()
        presentViewController(messageComposeVC, animated: true, completion: nil)
    } else {
        // Code to send error message
    }
}

Code to verify if message can be sent

func canSendText() -> Bool {
    return MFMessageComposeViewController.canSendText()
}

Code to compose the View Controller

func configuredMessageComposeViewController() -> MFMessageComposeViewController {
    let messageComposeVC = MFMessageComposeViewController()
    messageComposeVC.messageComposeDelegate = self  
    messageComposeVC.recipients = [SomeVariable]
    messageComposeVC.body = SomeText.text!
    return messageComposeVC
}

Here is how it looks like when the MFMessageComposeViewcontroller looks like for the first time.

So, I just deleted the whole thing and tried to create a new Scene and a new View controller from scratch. And it solved the problem. I ultimately used the same steps and same code as mentioned below in official Apple page.

https://developer.apple.com/library/ios/documentation/MessageUI/Reference/MFMessageComposeViewController_class/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM