Three methods are listed below.
New cell file
including. H. M. xib
Then add a label to the Xib file with the purpose of reusing the cell
First, initialize a class method in the Listcell to be called
+ (Listcell *) Cellwithtableview: (UITableView *) Tablaeview;
+ (Listcell *) Cellwithtableview: (UITableView *) Tablaeview
//{
static NSString *identifier = @ "Listcell";
Listcell *cell = [Tablaeview dequeuereusablecellwithidentifier:identifier];
if (!cell) {
cell = [[[NSBundle mainbundle]loadnibnamed:@ "Listcell" owner:self Options:nil]lastobject];
// }
//
return cell;
//
//}
Second, register the nib directly in the Tableviewcontroller
-(void) Viewdidload {
[Super Viewdidload];
[Self.tableview registernib:[uinib nibwithnibname:@ "Listcell" Bundle:[nsbundle Mainbundle]] ForCellReuseIdentifier: @ "Listcell"];
Uncomment the following line to preserve selection between presentations.
Self.clearsselectiononviewwillappear = NO;
Uncomment the following line to display a Edit button in the navigation bar for this view controller.
Self.navigationItem.rightBarButtonItem = Self.editbuttonitem;
}
Listcell *cell = [TableView dequeuereusablecellwithidentifier:@ "Listcell"];
Third, use Registerclass:[listcell class] but must initialize cell before use
-(Instancetype) Initwithstyle: (Uitableviewcellstyle) style Reuseidentifier: (NSString *) reuseidentifier
{
if (self = [super Initwithstyle:style Reuseidentifier:reuseidentifier]) {
self = [[[NSBundle mainbundle]loadnibnamed:@ "Listcell" owner:self Options:nil]lastobject];
}
return self;
}
Three methods as a result
PS: Note that the Awakefromnib method will be used every time the cell is called
The output is as follows
Iosbug Log-Tableviewcell multiplexing