2
林發送的電子郵件接收電子郵件和時間戳,但是您發送的電子郵件後,我想表明它是一個實現代碼如下完成的電子郵件和時間。我怎樣才能做到這一點?從保存在使用MFMailComposeViewController發送郵件一個實現代碼如下
我的表的代碼是基本
//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
}
這是我的郵件
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)
}
我怎樣才能在發送的電子郵件和時間顯示在我的表的代碼?先謝謝你。
那麼我將如何得到我發送的時間和電子郵件?我只需要這些信息而沒有別的。我對swift很陌生,所以我不太熟悉它是如何工作的。 – art3mis
請參閱更新我的答案 –
感謝更新。你只是給了我一個想法。在完成區域中,我可以發送剛剛使用的電子郵件和當前的NSDate,並將其發送到數組。不知道該怎麼做,但聽起來像個好主意。 – art3mis