我正在用swift为iPhone创建一个Todo应用程序。我想让tableview在tableview中显示任务的名称和时间。 Textlabel显示任务的正确名称,但detailTextLabel只显示Detail而不显示时间。swift ios中的tableview detailTextLabel
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!
}
Thaks人。没有看到:D – tc34
没问题!如果解决了它,请标记为答案。 (它做了什么;) – TheValyreanGroup