UITableView for iOS

Source: Internet
Author: User

UITableView for iOS

UITableViewDelegate protocol Method

 

Returns the height of each row of cells.

-(CGFloat) tableView :( UITableView *) tableView heightForRowAtIndexPath :( NSIndexPath *) indexPath

 

Returns the height of the partition header.

-(CGFloat) tableView :( UITableView *) tableView heightForHeaderInSection :( NSInteger) section

 

Returns the height of the partition area.

-(CGFloat) tableView :( UITableView *) tableView heightForFooterInSection :( NSInteger) section

 

Return the custom View of the partition header (you can use the reuse mechanism)

-(UIView *) tableView :( UITableView *) tableView viewForHeaderInSection :( NSInteger) section

 

Return the custom View of the partition footer (you can use the reuse mechanism)

-(UIView *) tableView :( UITableView *) tableView viewForFooterInSection :( NSInteger) section

 

How to execute when the attachment button on the right of the cell is clicked

-(Void) tableView :( UITableView *) tableView accessoryButtonTappedForRowWithIndexPath :( NSIndexPath *) indexPath

 

Method To be executed when a cell is to be selected

-(NSIndexPath *) tableView :( UITableView *) tableView willSelectRowAtIndexPath :( NSIndexPath *) indexPath

 

How to run an unselected Cell

-(NSIndexPath *) tableView :( UITableView *) tableView willDeselectRowAtIndexPath :( NSIndexPath *) indexPath

 

Method used to select a cell

-(Void) tableView :( UITableView *) tableView didSelectRowAtIndexPath :( NSIndexPath *) indexPath

 

How to cancel execution when selecting a cell

-(Void) tableView :( UITableView *) tableView didDeselectRowAtIndexPath :( NSIndexPath *) indexPath

 

Set the editing style of each cell

-(UITableViewCellEditingStyle) tableView :( UITableView *) tableView editingStyleForRowAtIndexPath :( NSIndexPath *) indexPath

UITableViewCellEditingStyleNone,

UITableViewCellEditingStyleDelete,

UITableViewCellEditingStyleInsert

 

Set the button title

-(NSString *) tableView :( UITableView *) tableView titleForDeleteConfirmationButtonForRowAtIndexPath :( NSIndexPath *) indexPath

 

Set whether to scale down Cells

-(BOOL) tableView :( UITableView *) tableView shouldIndentWhileEditingRowAtIndexPath :( NSIndexPath *) indexPath

 

How to execute a cell when it is about to be edited

-(Void) tableView :( UITableView *) tableView willBeginEditingRowAtIndexPath :( NSIndexPath *) indexPath

 

How to run the command when the cell is edited

-(Void) tableView :( UITableView *) tableView didEndEditingRowAtIndexPath :( NSIndexPath *) indexPath

 

How to move a cell

-(NSIndexPath *) tableView :( UITableView *) tableView targetIndexPathForMoveFromRowAtIndexPath :( NSIndexPath *) sourceIndexPath toProposedIndexPath :( NSIndexPath *) proposedDestinationIndexPath

 

Whether to display copy and paste of menu

-(BOOL) tableView :( UITableView *) tableView shouldShowMenuForRowAtIndexPath :( NSIndexPath *) indexPath

 

 

 

UITableViewDataSource protocol Method

 

 

Required:

Number of rows per Partition

-(NSInteger) tableView :( UITableView *) tableView numberOfRowsInSection :( NSInteger) section

 

Content of each cell (the cell has a reuse mechanism and can be customized)

-(UITableViewCell *) tableView :( UITableView *) tableView cellForRowAtIndexPath :( NSIndexPath *) indexPath

 

Not required:

Number of partitions (1 by default)

-(NSInteger) numberOfSectionsInTableView :( UITableView *) tableView

 

Partition header title

-(NSString *) tableView :( UITableView *) tableView titleForHeaderInSection :( NSInteger) section

 

Partition footer title

-(NSString *) tableView :( UITableView *) tableView titleForFooterInSection :( NSInteger) section

 

Set whether cells can be edited.

-(BOOL) tableView :( UITableView *) tableView canEditRowAtIndexPath :( NSIndexPath *) indexPath

 

Sets whether cells can be moved.

-(BOOL) tableView :( UITableView *) tableView canMoveRowAtIndexPath :( NSIndexPath *) indexPath

 

Set the index array to the right of the table

-(NSArray *) sectionIndexTitlesForTableView :( UITableView *) tableView

 

Set the ing between table indexes and partitions

-(NSInteger) tableView :( UITableView *) tableView sectionForSectionIndexTitle :( NSString *) title atIndex :( NSInteger) index

 

Method executed when the cell editing status is submitted (that is, the Add. delete button)

-(Void) tableView :( UITableView *) tableView commitEditingStyle :( UITableViewCellEditingStyle) editingStyle forRowAtIndexPath :( NSIndexPath *) indexPath

 

Method executed when the cell is moved (from the initial position to the target position)

-(Void) tableView :( UITableView *) tableView moveRowAtIndexPath :( NSIndexPath *) sourceIndexPath toIndexPath :( NSIndexPath *) destinationIndexPath

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Related Article

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.