我是一個初學者,剛開始幾個月就開始快速學習。請幫我解決計時器失效問題。隨意讓我感到很蠢:)。我知道這有點混亂,我願意指示下一次如何更好地做到這一點。快捷計時器在桌子內部無效查看單元格
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "CustomCell", for: indexPath) as! CustomCustomerCell
let appDelegate = UIApplication.shared.delegate as! AppDelegate
let object = appDelegate.Queuelist[indexPath.row]
if let genderInital = object.gender?.characters.first {
cell.genderlabel.text = " \(genderInital)"
}
object.timerStarted()
cell.waitedTimeLabel.text = "\(object.counter)"
cell.nameLabel.text = object.name
cell.languageLabel.text = object.language
cell.reasonLabel.text = object.reasonOfVisit
return cell
}
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
var customerName: String?
if let indexPathForName = tableView.indexPathForSelectedRow {
let appDelegate = UIApplication.shared.delegate as! AppDelegate
let selectedCustomer = appDelegate.Queuelist[indexPathForName.row]
customerName = selectedCustomer.name
}
let alertController = UIAlertController(title: customerName, message: "message", preferredStyle: .alert)
let cancelAction = UIAlertAction(title: "cancel", style: .cancel, handler: nil)
let editAction = UIAlertAction(title: "edit", style: .default) {action -> Void in
self.performSegue(withIdentifier: "addSegue", sender: alertController)
}
let takeCustomerAction = UIAlertAction(title: "take customer", style: .default) {
action -> Void in
if let indexpath = tableView.indexPathForSelectedRow {
let appDelegate = UIApplication.shared.delegate as! AppDelegate
let object = appDelegate.Queuelist[indexpath.row]
object.timer?.invalidate()
appDelegate.Queuelist.remove(at: indexpath.row)
appDelegate.storedQueuelist()
tableView.deleteRows(at: [indexPath], with: .fade)
}
}
alertController.addAction(takeCustomerAction)
alertController.addAction(editAction)
alertController.addAction(cancelAction)
self.present(alertController, animated: true, completion: nil)
}
你能解釋一下你越試圖完成的任務,你遇到了什麼問題,你嘗試過什麼辦法呢? – Jelle