我试图添加许多细节(字段)以在TableView中显示。通过CONCAT各个领域,并把在detailTextLabel如:如何在TableView中添加2个以上的detailTextLabel(Swift)
来源:
func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell!{
let cell: UITableViewCell = UITableViewCell(style: UITableViewCellStyle.Subtitle, reuseIdentifier:"test")
cell.textLabel.text = taskMgr.tasks[indexPath.row].name
cell.detailTextLabel.text = taskMgr.tasks[indexPath.row].desc
return cell
}
要
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell{
let cell:UITableViewCell = UITableViewCell(style: UITableViewCellStyle.Subtitle, reuseIdentifier: "Test")
cell.textLabel?.text=tasksList[indexPath.row].name
var yString = tasksList[indexPath.row].desc
var xString = tasksList[indexPath.row].amnt
var zString = xString+" "+yString
cell.detailTextLabel?.text=zString
return cell
}
谁能指出任何其他方式获得更好的代码,许多领域在视图中显示。
您可以使用自定义单元格。 – 2014-09-22 05:27:31
我搜索了“自定义单元格”找到了相关的代码和导师。 Thks – 2014-09-22 06:34:19
欢迎@ user3528013 – 2014-09-22 06:55:26