MailComposer didFinishWith结果在Swift 3.0中不起作用 [英] MailComposer didFinishWith results doesn't work in Swift 3.0

查看:120
本文介绍了MailComposer didFinishWith结果在Swift 3.0中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将我的应用转换为swift 3.0并且遇到 MailComposeController 的问题。当我调用函数时:

I converted my app to swift 3.0 and have a problem with MailComposeController. When I call function:

`func mailComposeController(_ controller: MFMailComposeViewController, didFinishWith result: MFMailComposeResult, error: Error?){
    controller.dismiss(animated: true, completion: nil)
}`

首先,我的信息有错误:

first of all I have an error with info:

对我来说有什么奇怪的,因为我复制了从 MFMailComposeViewControllerDelegate 粘贴此方法。当我将错误更改为 NSError 时,它可以正常工作,但我收到一条带有信息的警告,此方法需要是私有的避免这个警告。

what is strange for my, becouse I copy and paste this method from MFMailComposeViewControllerDelegate. When I change Error to NSError it works, but I receive a warning with info, this method needs to be private to avoid this warning.

当我在mailComposer中并看到电子邮件并尝试点击取消时,此控制器不会消失。如何解雇这个控制器的任何解决方案?

When I'm in mailComposer and see email and try to tap Cancel this controller doesn't disapear. Any solution how to dismiss this controller?

推荐答案

我有同样的问题,因为我导入 RealmSwift ,它有自己的错误 struct。

I had the same problem because I was importing RealmSwift, which has its own Error struct.

通过指定哪个错误类型修复它想。在这种情况下, Swift.Error

Fix it by specifying which Error type you want. In this case, Swift.Error.

完整代码:


func mailComposeController(_ controller: MFMailComposeViewController, didFinishWith result: MFMailComposeResult, error: Swift.Error?){
    controller.dismiss(animated: true, completion: nil)
}

这篇关于MailComposer didFinishWith结果在Swift 3.0中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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