약간의 코드에 오류가 있습니다. 나는 이것에 초보이고 나는 나 자신을 가르치려고 노력하고있다. 온라인 답변 대부분을 찾았지만이 특정 문제에 관해서는 아무것도 찾을 수 없습니다. 앱 내에서 이메일을 보내고 싶지만 언제든지 이메일 버튼을 누르면 MFMailViewController가 표시되지 않습니다. 내 UIButton이 작동하지 않는 것과 같습니다. 그러나 나는 그것이 IBAction이라는 것을 알고 있습니다. 지금까지 제 코드가 있습니다. 어떤 도움이라도 대단히 감사합니다. 장치 가 이메일을 보낼 수 없습니다 경우UIButton이 MFMailViewController를 불러 오지 않습니다.
import UIKit
import MessageUI
class RequestService: UIViewController,MFMailComposeViewControllerDelegate {
@IBOutlet weak var CustomerName: UITextField!
@IBOutlet weak var emailButton: UIButton!
@IBAction func sendEmail(_ sender: UIButton) {
if !MFMailComposeViewController.canSendMail() {
print("Mail services are not available")
let ComposeVC = MFMailComposeViewController()
ComposeVC.mailComposeDelegate = self
ComposeVC.setToRecipients(["[email protected]"])
ComposeVC.setSubject("New Support Ticket")
ComposeVC.setMessageBody(CustomerName.text!, isHTML: false)
self.present(ComposeVC, animated: true, completion: nil)
}
func mailComposeController(controller: MFMailComposeViewController,didFinishWithResult result:MFMailComposeResult, error: NSError?) {
// Check the result or perform other tasks.
// Dismiss the mail compose view controller.
controller.dismiss(animated: true, completion: nil)
}
}
}
시뮬레이터에서 테스트 하시겠습니까? 이것은 실제 iPhone 장치에서만 작동합니다. –