IOS 5.0 After Apple to simplify the code before tableview to the data source to request data before the use -registerNib:forCellReuseIdentifier: of "my_cell_id" registered nib, you can save every time to judge and initialize the cell code, if there is no cell in the reuse queue, Runtime will automatically help us generate and initialize an available cell.
[TableView registerclass: [yytableviewcell class] forcellreuseidentifier:@ " Uiy "];
[TableView registernib: [uinib nibwithnibname:@ ' Yytableviewcell ' bundle: Nil] forcellreuseidentifier:@ "Uiy"];
-(uitableviewcell *) TableView: (uitableview *) TableView Cellforrowatindexpath: ( Nsindexpath *) indexpath{
Yytableviewcell *cell = [TableView dequeuereusablecellwithidentifier:@ "Uiy"];
return cell;
}
Thus saving this sentence.
if (!cell) { //如果没有可重用的cell,那么生成一个
cell = [[UITableViewCell alloc] init];
}
IOS UITableView in-depth