ios - 从 UITableViewCell 标识符中获取类

标签 ios swift uitableview

我有一大堆 UITableViewCell 的子类,所有这些单元格都有一个返回单元格类型的估计高度的类方法...

所以我想做的是能够仅通过知道单元格标识符来调用该方法(我不想将 Switch 映射标识符与 Class 一起使用)。我想不出办法...

我知道有一个 NSClassFromString 但我不能使用它,因为我的对象没有继承自 NSObject...

有什么想法吗?

最佳答案

您可以将类名指定为单元标识符,然后执行此操作:

Class cellClass = NSClassFromString(cellIdentifier);

关于ios - 从 UITableViewCell 标识符中获取类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31865260/

相关文章:

ios - 如何保存倒数计时器的进度?

objective-c - 只显示很少的cell时,是否需要实现可重用的UITableViewCells的出队机制?

ios - 如何禁用 UITableViewcell iOS 中特定部分的 uitableViewCell 选择

ios - 分组的 UITableViewCell 中的 clipsToBounds 和 masksToBounds

ios - watchOS 2 WatchConnectivity Apple Watch 和 iPhone 之间的时间延迟,同时将数据从一个发送到另一个?

ios - 在 iOS 中创建文件和目录

ios - 显示 URL 中的文件文档

swift - 从现有 DispatchQueue 创建 SerialDispatchQueueScheduler 时,internalSerialQueueName 的正确用法是什么

ios - 在 TableView 中按月份倒序

ios - 如何在使用默认单元格值加载一次 View 后更新 UITableView 单元格(cell.detailTextLabel.text)的值