MFMailComposeViewController를 사용하여 전자 메일을 보내지 만 전자 메일을 보낸 후 전자 메일 및 테이블 뷰에서 완료된 시간을 표시하려고합니다. 어떻게해야합니까?보낸 이메일에서 보낸 전자 메일과 타임 스탬프를 테이블 뷰에 저장하십시오.
내 테이블 코드는이
func contactPicker(picker: CNContactPickerViewController, didSelectContactProperty contactProperty: CNContactProperty) {
//Checks if composer can sent email
if MFMailComposeViewController.canSendMail() {
let mail = MFMailComposeViewController()
mail.mailComposeDelegate = self
//Add the email to the recipient field
if let emailAddress = contactProperty.value as? String {
mail.setToRecipients([emailAddress])
}
//Dismisses the current view and presents the mail composer view
self.dismissViewControllerAnimated(true, completion: {() -> Void in
self.presentViewController(mail, animated: true, completion: nil)
})
} else {
print("send error")
}
}
//Dismiss Buttons for Mail Composer
func mailComposeController(controller:MFMailComposeViewController, didFinishWithResult result:MFMailComposeResult, error:NSError?) {
switch result {
case MFMailComposeResultCancelled:
print("Mail Cancelled")
case MFMailComposeResultSaved:
print("Mail Saved")
case MFMailComposeResultSent:
print("Mail Sent")
case MFMailComposeResultFailed:
print("Mail sent failure: \(error)")
default:
break
}
controller.dismissViewControllerAnimated(true, completion: nil)
}
가 어떻게 내 테이블에 표시 할 보낸 이메일과 시간을 얻을 수있는 메일 내 코드입니다
//This is empty, just to populate the empty table for now
var sentEmails = [String]()
//Number of Sections
func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 1
}
//Number of Rows
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return sentEmails.count
}
//Cell Configuration
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier(cellIdentifier, forIndexPath: indexPath)
let row = indexPath.row
cell.textLabel?.text = sentEmails[row] //Email here?
cell.detailTextLabel?.text = "time stamp"//maybe?
return cell
}
기본입니까? 미리 감사드립니다.
그래서 내가 보낸 시간과 이메일을 어떻게받을 수 있습니까? 나는이 정보 만 필요로했다. 나는 매우 익숙하지 않기 때문에 매우 익숙하지 않아 어떻게 작동하는지 알 수 없다. – art3mis
내 대답 –
에 대한 업데이트를 참조하십시오. 업데이트 해 주셔서 감사합니다. 방금 아이디어를 주셨습니다. 완료 영역에서 방금 사용했던 전자 메일과 현재 NSDate를 보내고 배열로 전송할 수 있습니다. 그것을하는 방법을 모르지만, 좋은 생각 같아. – art3mis