Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Design a UIView as the tableview cell with separate xib file

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?

like image 329
Arunkumar Avatar asked Dec 19 '22 23:12

Arunkumar


1 Answers

  1. You need to subclass UITableViewCell then you've to add a new 'View' file (refer to image below) enter image description here

  2. Delete the UIView file in .xib and add Table View Cell from object library.

3.Set the custom class for your cell

enter image description here

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];
}
like image 120
Ankur Arya Avatar answered Dec 28 '22 07:12

Ankur Arya