There are three ways to customize cells
-Code implementation
-Xib
-Storyboard (recommended)
In the storyboard, the action method is
1, the prototype cells in the TableView attribute is set to 1, the default is 1;
2, need to create a custom cell class;
3. Set table View cell class as a custom class;
Custom classes: (not difficult)
#import "CustomCell.h" @implementation customcell-(void) awakefromnib { //initialization code}-(void) setselected :(bool) selected animated: (bool) animated { [Super setselected:selected animated:animated]; Configure The view for the selected state} @end
The method of the data source protocol that must be implemented:
#pragma mark--uitableviewdatasource Protocol Method-(Nsinteger) TableView: (UITableView *) TableView numberofrowsinsection: ( Nsinteger) section{ return [Self.listteams count];} -(UITableViewCell *) TableView: (UITableView *) TableView Cellforrowatindexpath: (Nsindexpath *) indexpath{ // Defines a reusable Cell object static NSString *cellidentifier = @ "cell"; Customcell *cell = [TableView dequeuereusablecellwithidentifier:cellidentifier]; Nsuinteger row = [Indexpath row]; Nsdictionary *rowdict = [Self.listteams objectatindex:row]; Cell.name.text = [rowdict objectforkey:@ "name"]; NSString *imagepath = [rowdict objectforkey:@ "image"]; ImagePath = [ImagePath stringbyappendingstring:@ ". png"]; Cell.image.image = [UIImage Imagenamed:imagepath]; Cell.accessorytype = Uitableviewcellaccessorydisclosureindicator; return cell;}
Custom Cells (IOS)