I need to design a UIView as the tableview cell with separate xib file. I also tried it with creating a separate xib and design its view matches to tableview cell type. But it is failed, there is any programming guide to create a custom, reusable, tableview cell creation?
After creating custom tableview cell how can we add it to the table view?
You need to subclass UITableViewCell
then you've to add a new 'View' file (refer to image below)
Delete the UIView
file in .xib
and add Table View Cell
from object library
.
3.Set the custom class for your cell
CustomCell *cell = (CustomCell*)[tableView dequeueReusableCellWithIdentifier:identifier];
if (cell == nil) {
// Load the top-level objects from the custom cell XIB.
NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"CustomCell" owner:self options:nil];
// Grab a pointer to the first object (presumably the custom cell, as that's all the XIB should contain).
cell = [topLevelObjects objectAtIndex:0];
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With