【问题标题】:How to change CustomCell when it ends display?结束显示时如何更改CustomCell?
【发布时间】:2015-03-11 23:08:15
【问题描述】:

我想更改此代码:

override func tableView(tableView: UITableView, didEndDisplayingCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) {

}

像这样:

override func tableView(tableView: UITableView, didEndDisplayingCell cell: CustomCell, forRowAtIndexPath indexPath: NSIndexPath) {

}

但我收到一条错误消息。 我需要在 CustomCell 消失时更改它。我该如何处理?

【问题讨论】:

    标签: swift custom-cell tableviewcell


    【解决方案1】:

    使用原始方法签名,并使用可选转换访问CustomCell

    override func tableView(tableView: UITableView, didEndDisplayingCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) {
        if let cell = cell as? CustomCell {
            // do something with cell
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-25
      • 1970-01-01
      • 1970-01-01
      • 2021-12-06
      • 2017-08-22
      • 1970-01-01
      相关资源
      最近更新 更多