Is there a way to change the order of tableviewcells with animation? I want to slide up or down cells and change the ordering. But i dont know if it i开发者_JAVA技巧s possible with animation? I need help. Thanks,Tintin
You could do that UITableView's
edit mode.
Iphone sdk tutorial Add/Delete/Reorder UITableView row.
In this code dataArray is the name of my array you change it with your own array name
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
return YES;
}
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath {
NSString *stringToMove = [[self.dataArray objectAtIndex:sourceIndexPath.row] retain];
[self.dataArray removeObjectAtIndex:sourceIndexPath.row];
[self.dataArray insertObject:stringToMove atIndex:destinationIndexPath.row];
[stringToMove release];
[tableView reloadData];
}
精彩评论