gpt4 book ai didi

ios - 单击发送按钮之前的联系人按钮时出现黑屏

转载 作者:搜寻专家 更新时间:2023-11-01 06:13:23 25 4
gpt4 key购买 nike

只是试图让用户发送电子邮件。单击“联系人”按钮时,我进入黑屏而不是显示 mailComposer。

调试器响应

2018-05-14 11:10:59.465952-0400 App[2333:757177] 无法在 (UIButton) 上设置 (keyPath) 用户定义的检查属性:[ setValue:forUndefinedKey:]: 此类不是键值编码- 符合 key keyPath。

但是,只有在使用 SWReveal 函数从左向右滑动菜单时才会发生这种情况。从下面删除代码时,所有其他功能都可以正常工作。只有在使用下面的代码时,才会在按下“按钮接触”时出现黑屏。

import Foundation
import UIKit
import MessageUI

class SendEmailVC: MFMailComposeViewController, MFMailComposeViewControllerDelegate
{
@IBAction func Send_Tapped(_ sender: Any)
{

if MFMailComposeViewController.canSendMail()
{
contact()
let mailComposeViewController = configureMailController() //FIXED √
self.present(mailComposeViewController, animated: true, completion: nil)
}
else
{
showMailError()
}
}

func configureMailController() -> MFMailComposeViewController
{
let mailComposerVC = MFMailComposeViewController()
mailComposerVC.mailComposeDelegate = self

mailComposerVC.setToRecipients(["testing@gmail.com"])
mailComposerVC.setSubject("Hello")
mailComposerVC.setMessageBody("How are you doing?", isHTML: false)

return mailComposerVC
}


/*
* DON'T EDIT THE CODE BELOW.
*/


func showMailError()
{
let sendMailErrorAlert = UIAlertController(title: "Email failed to send", message: "Your device fail to send the email", preferredStyle: .alert)

let dismiss = UIAlertAction(title: "Dale", style: .default, handler: nil)
sendMailErrorAlert.addAction(dismiss)
self.present(sendMailErrorAlert, animated: true, completion: nil)
}

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

最佳答案

请使用代码在 swift 中打开带有如下扩展名的邮件。

extension SendEmailVC: MFMailComposeViewControllerDelegate {

func contact() {

if !MFMailComposeViewController.canSendMail() {
ROAlert.warningAlertUnderNavigation(ROConstants.More.kNoMailConfigured, onView: self.view)
return ()
}
let composeVC = MFMailComposeViewController()
composeVC.mailComposeDelegate = self
composeVC.setToRecipients([ROConstants.More.kContactEmail])
// Present the view controller modally.
self.present(composeVC, animated: true, completion: nil)
}

//MARK: - MFMailComposeViewControllerDelegate

func mailComposeController(_ controller: MFMailComposeViewController,
didFinishWith result: MFMailComposeResult, error: Error?) {
// Check the result or perform other tasks.

// Dismiss the mail compose view controller.
controller.dismiss(animated: true, completion: nil)
}

关于ios - 单击发送按钮之前的联系人按钮时出现黑屏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50312694/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com