ios - 在表格 View 中使用两个不同的单元格

标签 ios xcode swift mapkit

我想在表格 View 中显示两个不同的 map ,并且我之前使用过此代码,但现在 Xcode 提示单元格没有成员 nameLabeladdressLabel。我错过了什么吗?

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/

相关文章:

ios - iOS 中的深层链接 - 如果未安装应用程序,请导航至 Apple Store

ios - 按钮图像未显示在 UItextfield 的 rightView 中

ios - 在单个按钮单击中隐藏多个 UIButton

ios - 如何获取包含字典的数组

XCode 4.3.2 不会附加到调试器

ios - 我想要 collectionView 中的表节标题索引或节标题标题(_ :cellForItemAt:)

ios - tableView 中的图像在向左滑动删除时变大

iphone - 我应该单独制作 UIViewController 只是因为单行布局不同

ios - 机器人与 TestFlight 集成

iOS-图表 float 到整数 YAxis