我想在表格 View 中显示两个不同的 map ,并且我之前使用过此代码,但现在 Xcode 提示单元格没有成员 nameLabel
、addressLabel
。我错过了什么吗?
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
var cell: UITableViewCell!
if indexPath == 0 {
cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as! SummaryHeaderTableViewCell
cell.nameLabel.text = ""
cell.addressLabel.text = ""
cell.cityLabel.text = ""
let inspectionDate: String = detailItem!["dato"] as! String
cell.inspectionDateLabel.text = self.convertDateString(inspectionDate)
}
else
{
cell = tableView.dequeueReusableCellWithIdentifier("MapCell", forIndexPath: indexPath) as! MapTableViewCell
// Set map options
}
return cell
}
最佳答案
做类似的事情:
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
if indexPath == 0 {
let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as! SummaryHeaderTableViewCell
cell.nameLabel.text = ""
cell.addressLabel.text = ""
cell.cityLabel.text = ""
let inspectionDate: String = detailItem!["dato"] as! String
cell.inspectionDateLabel.text = self.convertDateString(inspectionDate)
return cell
}
else
{
let cell = tableView.dequeueReusableCellWithIdentifier("MapCell", forIndexPath: indexPath) as! MapTableViewCell
// Set map options
return cell
}
}
关于ios - 在表格 View 中使用两个不同的单元格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36302369/