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];
}