UITableView 行单元控制器
我的第一篇文章(所以请耐心等待)。
我正在建立一个 UITableView 组。每个部分都定义并存储在名为 TableViewSectionClass 的对象中。
不同部分的行会使用UITableCell的不同子类来使各个部分中的行显示不同。即一个部分中一行,另一部分中两行,另一部分中两行带有图像。
如何在 TableViewSectionClass 中存储“创建特定类型的行单元格所需的 UITableCell 类类型”?
My first post ever (so please be patient).
I am building a group UITableView. Each section is defined and stored in an object called TableViewSectionClass.
The rows is different section will use different sub-classes of UITableCell to make the rows in various sections display differently. I.e. One line in one section, two in another, two with an image in another.
How can I store the "UITableCell class type needed to create my particular kind of row cell" in my TableViewSectionClass?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以将其存储在
Class
类型的 property/ivar 中;您可以使用class
类方法检索适当的类对象,当然,类似于tableViewSectionClass.tableCellClass = [MyUITableCellClass class]
。在调用类方法(例如 alloc)时,您可以像使用裸类名一样使用此类对象:
[[self.tableCellClass alloc] initWithStyle:...reuseIdentifier:[self.tableCellClass description]]
。You can store it in a property/ivar of type
Class
; you retrieve the appropriate class object using theclass
class method, of course, something liketableViewSectionClass.tableCellClass = [MyUITableCellClass class]
.You can use this class object just as you would a bare class name when calling class methods such as alloc:
[[self.tableCellClass alloc] initWithStyle:... reuseIdentifier:[self.tableCellClass description]]
.