1

我的项目中有一个 UITableViewCell,我想在几个 UITableView 中重用它。有没有一种方法可以重用它们而无需每次在情节提要中设置 UILabel 等?

4

2 回答 2

0

在 cellForRowAtIndex 中,您可以参考自定义单元格:

- (UITableViewCell *)tableView (UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
CustomCell *cell = ...
cell.labelName.text = ...;
Return cell;

}

于 2015-02-19T18:11:37.630 回答
0

您需要创建 UITableViewCell 类并将其注册到您的表中

- (void)viewDidLoad
{
    [super viewDidLoad];
    [self.tableView registerClass:<RegisteredClass> forCellReuseIdentifier:<ReuseIdentifier>];
}
于 2015-02-19T18:13:56.017 回答