简体   繁体   English

使用带有某些单元的情节提要的自定义UITableViewCell

[英]Custom UITableViewCell using storyboard with some cells

I have a TableView in which a most cells are pretty standard. 我有一个TableView,其中大多数单元格是非常标准的。 I make them buy using static cells in Storyboard. 我让他们使用情节提要中的静态单元格进行购买。 However, one cell I would like to customize probably using an XIB file so I would need to load it programmatically. 但是,我可能想使用XIB文件来自定义一个单元,所以我需要以编程方式加载它。

In the TableView's data source, is it possible to handle loading XIB view for this particular cell only, while leaving other cells to what's delineated in the static cells in the Storyboard? 在TableView的数据源中,是否可以仅为此特定单元格处理加载XIB视图,而将其他单元格保留在情节提要中的静态单元格中所描绘的内容呢? Or is it an all or nothing thing where I need to just give up using static cells altogether? 还是只需要完全放弃使用静态电池的全有还是全无?

The rationality for doing this is that I would like to make Storyboard to look as close to the real thing as possible. 这样做的合理性是,我希望使Storyboard看起来尽可能接近真实事物。 Right now if I provide a data source, the static cells in the storyboard would have no effect on the actual output and is not in any sense linked to the actual output. 现在,如果我提供数据源,情节提要中的静态单元格将不会影响实际输出,并且在任何意义上都不会与实际输出链接。

Yes, it is possible. 对的,这是可能的。 Set the custom class for the custom cell. 为自定义单元格设置自定义类。 If you wish to customise it from code, just connect it as an IBOutlet to the UITableViewController. 如果希望通过代码自定义它,只需将其作为IBOutlet连接到UITableViewController。

单元格自定义类

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM