I have a UITableViewCell in my project that I want to reuse in a few UITableViews. Is there a way to reuse them without setting up UILabels, etc each time in the Storyboard?
Asked
Active
Viewed 512 times
2 Answers
0
In cellForRowAtIndex, you can refer to the custom cell:
- (UITableViewCell *)tableView (UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
CustomCell *cell = ...
cell.labelName.text = ...;
Return cell;
}

Aadesh
- 162
- 1
- 8
-
My question is more of a storyboard question I think. How do I reuse a cell without having to set the layout every time. – Brian Kalski Feb 19 '15 at 21:05
-
Create a class that subclasses uitableviewcell, and refer to that for each prototype cell – Aadesh Feb 20 '15 at 02:24
-
1That doesn't specify the layout of UI elements though. – Brian Kalski Feb 20 '15 at 02:29
0
You need to create your UITableViewCell class and register it for your tables
- (void)viewDidLoad
{
[super viewDidLoad];
[self.tableView registerClass:<RegisteredClass> forCellReuseIdentifier:<ReuseIdentifier>];
}

LLIAJLbHOu
- 1,313
- 12
- 17