Jam*_*ord 1 custom-cell tableviewcell swift
我想更改此代码:
override func tableView(tableView: UITableView, didEndDisplayingCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) {
}
Run Code Online (Sandbox Code Playgroud)
像那样:
override func tableView(tableView: UITableView, didEndDisplayingCell cell: CustomCell, forRowAtIndexPath indexPath: NSIndexPath) {
}
Run Code Online (Sandbox Code Playgroud)
但是我收到一条错误消息.当它消失时,我需要更改我的CustomCell.我怎么处理这个?
使用原始方法签名,并使用可选的转换来访问CustomCell:
override func tableView(tableView: UITableView, didEndDisplayingCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) {
if let cell = cell as? CustomCell {
// do something with cell
}
}
Run Code Online (Sandbox Code Playgroud)