UITableView: This section only describes the proxy method and uitableview sorting.

Source: Internet
Author: User

UITableView: This section only describes the proxy method and uitableview sorting.

# Pragma mark-proxy method

# Pragma mark setting cell table height

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

Return 60;

}

# Pragma mark is called when cell editing is enabled

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

If (editingStyle! = UITableViewCellEditingStyleDelete) return;

// 1. delete data from the data source

[_ Persons removeObject: _ persons [indexPath. row];

// 2. Reload data

[Self. tableView reloadData];

}

# Pragma mark is called when cell sorting is implemented

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

// 1. extract the data to be moved and delete it.

Person * p = _ persons [sourceIndexPath. row];

[_ Persons removeObject: p];

// 2 Add the data to be moved to the destination location

[_ Persons insertObject: p atIndex: destinationIndexPath. row];

}

 

 

 

# Delete a pragma mark listener

-(IBAction) remove :( UIBarButtonItem *) sender {

// Self. tableView. editing = YES; // enter the editing mode

BOOL result =! Self. tableView. isEditing;

[Self. tableView setEditing: result animated: YES];

}

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.