First, the agent method of UITableView
#pragma mark the height of each line
-(CGFloat) TableView: (UITableView *) TableView Heightforrowatindexpath: (Nsindexpath *) Indexpath
#pragma mark selects a row and then calls
-(void) TableView: (UITableView *) TableView Didselectrowatindexpath: (Nsindexpath *) Indexpath
#pragma mark cancels a row, it calls
-(void) TableView: (UITableView *) TableView Diddeselectrowatindexpath: (Nsindexpath *) Indexpath
#pragma mark is invoked when the user submits an edit (e.g. click on the "Delete" button)
As long as this method is implemented, the swipe delete function is added by default.
-(void) TableView: (UITableView *) TableView Commiteditingstyle: (uitableviewcelleditingstyle) Editingstyle Forrowatindexpath: (Nsindexpath *) Indexpath
#pragma mark, when you move a row, the cell calls
As long as this method is implemented, the sort function is added by default.
-(void) TableView: (UITableView *) TableView Moverowatindexpath: (Nsindexpath *) Sourceindexpath Toindexpath: ( Nsindexpath *) Destinationindexpath
Second, modify the state of the cell
1. It is best to modify the status of the cell by modifying the model data
2. Steps to Modify
1> Modifying model data
2> Refresh Table
* Overall Refresh: Reloaddata (most important)
* Local refresh: reloadrowsatindexpaths:withrowanimation:
Iii. Common methods of UITableView
1. Uncheck a row (remove the default blue background when cell is selected)
-(void) Deselectrowatindexpath: (Nsindexpath *) Indexpath animated: (BOOL) animated;
2. Partial refresh (refresh only rows loaded in the indexpaths array)
-(void) Reloadrowsatindexpaths: (Nsarray *) indexpaths withrowanimation: (uitableviewrowanimation) animation
3. Overall refresh (each row in the screen is refreshed)
-(void) reloaddata;
4. Directly delete the number of lines on the interface (requires that the model data also delete the corresponding number)
-(void) Deleterowsatindexpaths: (Nsarray *) indexpaths withrowanimation: (uitableviewrowanimation) animation
5. Set edit mode
@property (nonatomic,getter=isediting) BOOL editing;
-(void) setediting: (BOOL) editing animated: (bool) animated;
6. Load plist put the plist in the array
1. Loaded Plist,array are nsdictionary objects
NSString *path = [[NSBundle mainbundle] pathforresource:@ "shops" oftype:@ "plist"];
Nsarray *array = [Nsarray Arraywithcontentsoffile:path];
2. Convert a Dictionary object in an array into a shop model object
_shops = [Nsmutablearray array];
For (nsdictionary *dict in array) {
2.1. Create a model
Shop *s = [[Shop alloc] initwithdict:dict];
Shop *s = [shop shopwithdict:dict];
2.2. Putting model objects into arrays
[_shops addobject:s];
}
Attention:
Whether it's a partial refresh or a whole refresh, the principle is:
UITableView sends the corresponding message back to the data source (DataSource) and the agent (delegate), eventually presenting the resulting data
Proxy methods for UITableView