IOS TableView Full explanation

Source: Internet
Author: User

Show how many groups

-(Nsinteger) Numberofsectionsintableview: (UITableView *) TableView

Show the head of each group

-(uiview*) TableView: (UITableView *) TableView viewforheaderinsection: (nsinteger) Section

Show the tail of each group

-(uiview*) TableView: (UITableView *) TableView viewforfooterinsection: (nsinteger) Section

Shows how high the trailing title of each group is

-(CGFloat) TableView: (UITableView *) TableView heightforfooterinsection: (Nsinteger) section{

return cgfloat_min;

}

Shows how high the header title is for each group

-(CGFloat) TableView: (UITableView *) TableView heightforheaderinsection: (nsinteger) Section

{

return cgfloat_min;

}

Show each group header title name

-(nsstring*) TableView: (UITableView *) TableView titleforheaderinsection: (nsinteger) Section

Show each group footer title name

-(nsstring*) TableView: (UITableView *) TableView titleforfooterinsection: (nsinteger) Section

Show each set of title indexes

-(Nsarray *) Sectionindextitlesfortableview: (UITableView *) TableView

Show how many rows each group has

-(Nsinteger) TableView: (UITableView *) TableView numberofrowsinsection: (nsinteger) Section

Show row height for each group

-(CGFloat) TableView: (UITableView *) TableView Heightforrowatindexpath: (Nsindexpath *) Indexpath

Show content

-(UITableViewCell *) TableView: (UITableView *) TableView Cellforrowatindexpath: (Nsindexpath *) Indexpath

Turn editing features on or off

if ([self.table isediting]) {

[Self.table Setediting:no Animated:yes];

}else{

[Self.table Setediting:yes Animated:yes];

}

Whether the corresponding row can be edited

-(BOOL) TableView: (UITableView *) TableView Caneditrowatindexpath: (Nsindexpath *) Indexpath

Set editing style

-(Uitableviewcelleditingstyle) TableView: (UITableView *) TableView Editingstyleforrowatindexpath: (Nsindexpath *) indexpath{

Uitableviewcelleditingstylenone,

Uitableviewcelleditingstyledelete, deleting

Uitableviewcelleditingstyleinsert add

}

Submit edits (left slide delete and add)

-(void) TableView: (UITableView *) TableView Commiteditingstyle: (uitableviewcelleditingstyle) Editingstyle Forrowatindexpath: (Nsindexpath *) Indexpath {

if (Editingstyle = = Uitableviewcelleditingstyledelete) {//delete

[Self.servicearry RemoveObjectAtIndex:indexPath.row];

[Self.tableview Deleterowsatindexpaths:@[indexpath] withrowanimation:uitableviewrowanimationbottom];//Delete Refresh

}

else if (Editingstyle = = Uitableviewcelleditingstyleinsert) {//Add

[Datas insertobject:@ "AB" AtIndex:indexPath.row];

[Self.table Insertrowsatindexpaths:@[indexpath] withrowanimation:uitableviewrowanimationbottom];//Add Refresh

}

}

Set whether you can move

-(BOOL) TableView: (UITableView *) TableView Canmoverowatindexpath: (Nsindexpath *) Indexpath

Submit a move result

-(void) TableView: (UITableView *) TableView Moverowatindexpath: (Nsindexpath *) Sourceindexpath Toindexpath: ( Nsindexpath *) destinationindexpath{

Save the data you want to move first

ID moveobj = [datas ObjectAtIndex:sourceIndexPath.row];

Delete the data to be moved from the array

[Datas RemoveObjectAtIndex:sourceIndexPath.row];

Insert the data you want to move to the target location

[Datas insertobject:moveobj AtIndex:destinationIndexPath.row];

}

Click events per row

-(void) TableView: (UITableView *) TableView Didselectrowatindexpath: (Nsindexpath *) Indexpath

IOS TableView Full explanation

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.