【发布时间】:2014-09-22 04:12:56
【问题描述】:
我尝试添加许多详细信息(字段)以在 TableView 中显示。通过连接每个字段并放入 detailTextLabel 例如:
发件人:
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
}
任何人都可以指出任何其他方法,以便更好地在视图中显示许多字段的代码。
【问题讨论】:
-
您可以使用自定义单元格。
-
我搜索“自定义单元格”找到了相关代码和导师。谢谢
-
欢迎@user3528013