【发布时间】:2016-11-18 19:08:22
【问题描述】:
我正在为 iPhone 创建一个带有 swift 的 Todo 应用程序。我希望 tableview 在 tableview 中显示任务的名称和时间。 Textlabel 显示任务的正确名称,但 detailTextLabel 仅显示 Detail 而不是时间。
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
var cell = tableView.dequeueReusableCell(withIdentifier: "cell") as UITableViewCell!
let task = tasks[indexPath.row]
if task.done {
cell?.textLabel!.text = "‼️\(task.name!)"
task.time = cell!.detailTextLabel!.text
} else {
cell?.textLabel!.text = "\(task.name!)"
task.time = cell!.detailTextLabel!.text
}
return cell!
}
【问题讨论】:
标签: ios iphone swift uitableview tableview