本文介绍了MFMailComposeViewController在iOS 13模拟器和设备中的行为有所不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我正在尝试在应用程序中显示MFMailComposeViewController.

I'm trying to display MFMailComposeViewController in an app.

if MFMailComposeViewController.canSendMail() {
    let mailComposeViewController = MFMailComposeViewController()
    mailComposeViewController.navigationBar.tintColor = .white
    mailComposeViewController.mailComposeDelegate = self
    mailComposeViewController.setToRecipients(["[email protected]"])
    mailComposeViewController.setSubject("Feedback")
    present(mailComposeViewController, animated: true)
} else {
    print("This device is not configured to send email. Please set up an email account.")
}

在iOS 12中,它显示没有问题.在模拟器和设备中.

In iOS 12, it shows up without an issue. In both simulator and device.

但是当我在运行iOS 13的设备上运行同一项目时,看起来像这样.

But when I run the same project on a device running iOS 13, it looks like this.

导航栏颜色消失了.另外,发送按钮也不可见.

The navigation bar color is gone. Also the send button is also invisible.

所以我添加了mailComposeViewController.navigationBar.backgroundColor = .mv_primary,但是它仍然没有显示在设备上.奇怪的是,背景色显示在模拟器中.

So I added mailComposeViewController.navigationBar.backgroundColor = .mv_primary but it still doesn't show on the device. Strangely the background color shows in the simulator.

但是有一种奇怪的行为.当我在模拟器中运行MFMailComposeViewController时,它会立即自动关闭.

However there's a strange behavior. The MFMailComposeViewController immediately dismisses by itself when I run it in the simulator.

Xcode控制台中也会显示以下错误.

The following error also shows up in the Xcode console.

我猜奇怪的解雇错误是Xcode错误.但是,如何解决背景色和发送按钮未显示在设备中的问题?

I guess the weird dismiss error is a Xcode bug. But how do I fix the background color and the send button not showing up in the device?

这是我设置所有与导航栏相关的样式的方法.

This is how I set all the navigationbar related styles.

UINavigationBar.appearance().barTintColor = .mv_primary
UINavigationBar.appearance().tintColor = .white
UINavigationBar.appearance().titleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.white]
if #available(iOS 11.0, *) {
    UINavigationBar.appearance().largeTitleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.white]
}

演示项目

推荐答案

这是iOS 13中的新UI样式.您可以在Storyboard中禁用它或设置手册.在iOS 13全屏中呈现模式

This is new UI Style from iOS 13. You can disable it in Storyboard or set manual.Presenting modal in iOS 13 fullscreen

这篇关于MFMailComposeViewController在iOS 13模拟器和设备中的行为有所不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 14:07