common methods in Uitableviewdatasource protocol
1. Set the right side Index Value
-(nsarray *) Sectionindextitlesfortableview: ( UITableView *) TableView
2. set up grouping identities
-(nsstring *) TableView: ( UITableView *) TableView titleforheaderinsection: (nsinteger) section
3.set Number of groups
- (Nsinteger) Numberofsectionsintableview: (UITableView*) TableView
4. Set the number of rows
-(nsinteger) TableView: ( UITableView *) TableView numberofrowsinsection: (nsinteger) section
5.Createcell (using the reuse mechanism, as in the following example)
- (UITableViewCell*) TableView: (UITableView*) TableView Cellforrowatindexpath: (Nsindexpath*) Indexpath
{
1.creating a reuse identifier
StaticNSString*identifier =@ "Reuse";
2. go to the reuse queue to take reusable cells from identifiers
Addressbookcell *cell = [TableViewdequeuereusablecellwithidentifier: Identifier];
3. determine whether to obtain a reusable cell ( finally space free )
if (!cell) {
cell = [[[addressbookcellalloc]initwithstyle: Uitableviewcellstyledefaultreuseidentifier: identifier]autorelease ];
}
return cell;
}
6.SetTableViewthe edit state of each row(YES, editable)
- (BOOL) TableView: (UITableView*) TableView Caneditrowatindexpath: (Nsindexpath*) Indexpath
{
return YES
}
7.edit button's Click event ( triggered when the edit button is clicked )
-(void) setediting: ( BOOL ) Editing animated: (BOOL) animated
8. Triggers when an edit operation is committed
-(void) TableView: ( UITableView *) TableView Commiteditingstyle: (uitableviewcelleditingstyle) Editingstyle Forrowatindexpath :(nsindexpath *) Indexpath
9. Set tableView If each row is allowed to move (YES, movable)
-(BOOL) TableView: ( UITableView *) TableView Canmoverowatindexpath: (nsindexpath *) Indexpath
{
return YES
}
triggering after committing a move operation
-(void) TableView: ( UITableView *) TableView Moverowatindexpath: (nsindexpath *) Sourceindexpath Toindexpath: ( Nsindexpath *) Destinationindexpath
common methods in Uitableviewdelegate protocol
1. Set the row height
-(cgfloat) TableView: ( UITableView *) TableView Heightforrowatindexpath: (nsindexpath *) Indexpath
{
return;
}
2. trigger When cell is selected
-(void) TableView: ( UITableView *) TableView Didselectrowatindexpath: (nsindexpath *) Indexpath
3. set the edit style for Tableviewcell ( insert / Delete )
-(uitableviewcelleditingstyle) TableView: ( UITableView *) TableView Editingstyleforrowatindexpath: (nsindexpath *) Indexpath
4. set the text shown above when you click the Edit button , such as show delete
-( nsstring Span style= "font:18.0px Menlo" > *) TableView: ( uitableview *) TableView Titlefordeleteconfirmationbuttonforrowatindexpath: ( Span style= "color: #6122ae; font:18.0px Menlo ">nsindexpath *) Indexpath ns_available_ios ( 3 _0) { return @ " delete " ;}
5. Set the cell Move location
-(nsindexpath *) TableView: ( UITableView *) TableView Targetindexpathformovefromrowatindexpath: (nsindexpath *) Sourceindexpath Toproposedindexpath: (nsindexpath *) Proposeddestinationindexpath
Common methods in IOS, Uitableviewdatasource, and uitableviewdelegate protocols