-1

The cancel button on right top corner after a message composer has been presented is not visible in iOS 11 devices. As shown in the screenshot, cancel button works but is not visible. Once we press on it, the screen dismisses.enter image description here

rajtharan-g
  • 432
  • 5
  • 14

1 Answers1

0

I have tried like this:

class ViewController: UIViewController, MFMessageComposeViewControllerDelegate {

override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.
}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}


@IBAction func Messages(_ sender: UIButton) {
    if MFMessageComposeViewController.canSendText() == true {
        let recipients:[String] = ["1500"]
        let messageController = MFMessageComposeViewController()
        messageController.messageComposeDelegate  = self
        messageController.recipients = recipients
        messageController.body = "Your_text"
        self.present(messageController, animated: true, completion: nil)
    } else {
        //handle text messaging not available
    }
}

func messageComposeViewController(_ controller: MFMessageComposeViewController, didFinishWith result: MessageComposeResult) {
    controller.dismiss(animated: true, completion: nil)
}
    
}
  1. Added Messages and MessageUI frameworks and imported in view controller.

  2. Screenshot:

Image: enter image description here

Community
  • 1
  • 1
Abhishek Thapliyal
  • 3,497
  • 6
  • 30
  • 69