暂时只是实现同一个section里的移动,要跨section移动的话,稍微懂点脑筋就行~
代码:
- - (void)tableView:(UITableView *)tableViewmoveRowAtIndexPath:(NSIndexPath *)fromIndexPathtoIndexPath:(NSIndexPath *)toIndexPath {
- if (fromIndexPath != toIndexPath) {
- id object = [self.dataMutableArray objectAtIndex:fromIndexPath.row];
- [object retain];
- [self.dataMutableArray removeObjectAtIndex:fromIndexPath.row];
- if (toIndexPath.row > [self.dataMutableArray count]) {
- [self.dataMutableArray addObject:object];
- }
- else {
- [self.dataMutableArray insertObject:object atIndex:toIndexPath.row];
- }
- [object release];
- }
- }
- - (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
- return YES;
- }