MFMailComposeViewController在iOS 13模拟器和设备中的行为有所不同 [英] MFMailComposeViewController behaves differently in iOS 13 simulator and device

查看:284
本文介绍了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(["support@gmail.com"])
    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.

[公共] [FBSSystemService] [0x5f27]处理以下请求的打开请求时出错 com.apple.MailCompositionService:{ userInfo = { FBSOpenApplicationRequestID = 0x5f27; } 底层错误=; } 2019-11-01 14:40:05.214158 + 0530 MailCompose [11289:262267] [声明]连接 请求无效而没有恢复我们的_serviceSessionConnection. 这是一个错误. 2019-11-01 14:40:05.216901 + 0530 MailCompose [11289:262054] [常规] #CompositionServices _serviceViewControllerReady:NSError域= _UIViewServiceInterfaceErrorDomain代码= 0

[Common] [FBSSystemService][0x5f27] Error handling open request for com.apple.MailCompositionService: { userInfo = { FBSOpenApplicationRequestID = 0x5f27; } underlyingError = ; } 2019-11-01 14:40:05.214158+0530 MailCompose[11289:262267] [Assert] Connection request invalidated without resuming our _serviceSessionConnection. This is an error. 2019-11-01 14:40:05.216901+0530 MailCompose[11289:262054] [General] #CompositionServices _serviceViewControllerReady: NSError Domain=_UIViewServiceInterfaceErrorDomain Code=0

我猜奇怪的解雇错误是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模拟器和设备中的行为有所不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆