이것은 샘플 코드를 해고하지 않습니다 MFMailComposeViewController는
import UIKit
import MessageUI
class ViewController: UIViewController, MFMailComposeViewControllerDelegate {
@IBAction func showEmail(sender : AnyObject) {
var emailTitle = "Test Email"
var messageBody = "This is a test email body"
var toRecipents = ["[email protected]"]
var mc: MFMailComposeViewController = MFMailComposeViewController()
mc.mailComposeDelegate = self
mc.setSubject(emailTitle)
mc.setMessageBody(messageBody, isHTML: false)
mc.setToRecipients(toRecipents)
self.presentViewController(mc, animated: true, completion: nil)
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func mailComposeController(controller:MFMailComposeViewController, didFinishWithResult result:MFMailComposeResult, error:NSError) {
switch result.value {
case MFMailComposeResultCancelled.value:
NSLog("Mail cancelled")
case MFMailComposeResultSaved.value:
NSLog("Mail saved")
case MFMailComposeResultSent.value:
NSLog("Mail sent")
case MFMailComposeResultFailed.value:
NSLog("Mail sent failure: %@", [error.localizedDescription])
default:
break
}
self.dismissModalViewControllerAnimated(true)
// self.dismissViewControllerAnimated(true, completion: nil)
}
}
I 버튼, showEmail 실행 및 전송 이메일 양식을 표시하는 기능을 밀어
. "보내기"를 클릭하면 모든 것이 정상적으로 작동하고 메일이 전송 된 다음 mailComposeController이 실행됩니다. NSLog는 "Mail sent" 레이블을 표시하고 초기 화면이 다시 나타납니다. 되고, "취소" "보내기"와 - 나는 송신 메일의 대화 상자에있어 경우, 을 클릭 기능 mailComposeController는, 두 개의 버튼이 작동하지 않는, 버튼을 누른 대화는 사라지지 않는다 "취소" 회색의 색상이 그대로 유지됩니다.
무엇이 잘못 되었나요?
젠장! :-) 이미 수백 가지 옵션을 경험했습니다. :-) –
이 버그는 여전히 지속됩니까? Xcode6.0.1에서 동일한 문제가 발생했습니다 – BaSha
presentingViewController는 presentViewController를 해제하는 책임이 있습니다. – Yariv