Proxy methods for UITableView

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.