![](/img/trans.png)
[英]Cannot convert value of type 'UITableViewCell' to specified type
[英]Swift 3 Generic cannot convert value of type UITableViewCell
我有一个可以接受泛型类型的自定义单元格。
class MyCell<T>: UITableViewCell where T: MyCellDataSource, T: MyCellDelegate
如何在出列单元格时使用它或输入或推断它?
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
在Swift 3.0中,我最近使用了相同的实现。 我通过以下代码解决了这个问题。
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as? MyCell<TName>
//Configure cell here
return cell!
希望能帮助到你
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.