我想從我的應用程序發送郵件。我正在做SWIFT的第一步,並且我堅持了一個觀點。我想按下按鈕並打開郵件。你能告訴我如何做按鈕連接?我認爲它應該是一個動作,但我不知道在哪裏把它的代碼如何從我的iOS應用程序發送郵件 - SWIFT
import UIKit
import MessageUI
class ViewController: UIViewController, MFMailComposeViewControllerDelegate {
func sendEmail() {
let mailVC = MFMailComposeViewController()
mailVC.mailComposeDelegate = self
mailVC.setToRecipients([])
mailVC.setSubject("Subject for email")
mailVC.setMessageBody("Email message string", isHTML: false)
presentViewController(mailVC, animated: true, completion: nil)
}
// MARK: - Email Delegate
func mailComposeController(controller: MFMailComposeViewController, didFinishWithResult result: MFMailComposeResult, error: NSError?) {
controller.dismissViewControllerAnimated(true, completion: nil)
}
override func viewDidLoad() {
super.viewDidLoad()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
}
我一定要刪除FUNC sndEmail()? – jonathan
@jonathan只是改變FUNC sendEmail(){線 – gvuksic
抱歉愚蠢的問題,但是當它就是這樣..它依然犯規工作 – jonathan