Reorder table cell using custom button

I am developing an application, I have a UITableView, I use the following code to control reordering:

- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath{ return YES; } - (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath { return UITableViewCellEditingStyleNone; } -(NSIndexPath *)tableView:(UITableView *)tableView targetIndexPathForMoveFromRowAtIndexPath:(NSIndexPath *)sourceIndexPath toProposedIndexPath:(NSIndexPath *)proposedDestinationIndexPath{ if(proposedDestinationIndexPath.section==0 && proposedDestinationIndexPath!=sourceIndexPath){ return proposedDestinationIndexPath; } else{ return sourceIndexPath; } } -(BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath{ return YES; } -(void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath{ //move rows } 

It works fine, but I want to change the position of the Reorder button and implement something like the Music Queue list on iOS 8.4.

I want to change the reorder button so that it is in the scroll list whose contents are in the cell. Screenshot: enter image description here

Thanks in advance:)

+1
source share
2 answers

I solved my problem using the code here to reorder, and then I used the UITableView delegates for later deletion.

 -(UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath{ return UITableViewCellEditingStyleDelete; } -(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath{ //Remove selected cell from tableview and you data source } } 
0
source

According to this tutorial, you can set the UITableViewCellReorderControl as part of the UITableViewCellContentView so that it moves with the contents of the cell:

 - (void) tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath { UIView *reorderControl = [cell huntedSubviewWithClassName:@"UITableViewCellReorderControl"]; UIView *contentView = [cell huntedSubviewWithClassName:@"UITableViewCellContentView"]; UIView *resizedGripView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetMaxX(reorderControl.frame), CGRectGetMaxY(reorderControl.frame))]; [resizedGripView addSubview:reorderControl]; [contentView addSubview:resizedGripView]; // Original transform CGAffineTransform transform = CGAffineTransformIdentity; // Move reorderControl to the left with an arbitrary value transform = CGAffineTransformTranslate(transform, -100, 0); [resizedGripView setTransform:transform]; } 
+1
source

All Articles