iosswiftmfmailcomposeviewcontroller

Strange MFMailComposeViewController behaviour in iOS 14 (Swift)


I implemented MFMailComposeViewController in my app. But when I scroll down and then scroll up the navigationBar starts to flicker and doesn't show me a large title the first time. For it to be displayed, I need to scroll very hard from the top to the bottom of the screen.

Another strange behavior, they may be related. If I open this form in another application (in which it works well) and then return to my application, it starts working well in my application until I remove it and reopen it.

Maybe it's important: openMailApp func is called from objc ViewController class.

The issue appears only in iOS14, in previous version it's ok.

class func openMailApp(vc: UIViewController, delegate: MFMailComposeViewControllerDelegate) {
        let mailComposeViewController = MFMailComposeViewController()

        if MFMailComposeViewController.canSendMail() {
            mailComposeViewController.mailComposeDelegate = delegate
            mailComposeViewController.setToRecipients(["email@gmail.com"])
            mailComposeViewController.setSubject("My subject")
            mailComposeViewController.setMessageBody(".........\n...", isHTML: false)

            vc.present(mailComposeViewController, animated: true, completion: nil)
        }
}

example


Solution

  • I had a very similar problem to yours.

    I figured it was due to the appearance proxy like below:

    UINavigationBar.appearance().translucent = false

    Effects of this are visible to the entire application - also in MFMailComposeViewController.

    Try to set UINavigationBar.appearance().translucent = true. In my case it fixed the problem.