我正在制作一个我想要移动行的应用程序。所以我可以通过
来完成[self.tableList setEditing:YES animated:YES];
其中“ tableList ”是我的表名,但每当我运行此行时。我无法获取移动的图标,通常在右侧移动单元格而不是我得到用于删除单元格左侧的行的图标。
请帮助我移动细胞并询问您是否需要澄清我的问题..
感谢。
答案 0 :(得分:1)
您需要实现以下两种方法
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
return YES;
}
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath {
//do code according to your requirements of app
//if you do not write ant thing in the method then also your row will be moved.
NSString *stringToMove = [[self.dataArray objectAtIndex:sourceIndexPath.row] retain];
[self.dataArray removeObjectAtIndex:sourceIndexPath.row];
[self.dataArray insertObject:stringToMove atIndex:destinationIndexPath.row];
[stringToMove release];
[tableView reloadData];
}
答案 1 :(得分:0)
使用此链接的aple并向下滚动到apple如何移动或滚动行。 cheerz:)
- beginUpdates - endUpdates - insertRowsAtIndexPaths:withRowAnimation: - deleteRowsAtIndexPaths:withRowAnimation: - moveRowAtIndexPath:toIndexPath: - insertSections:withRowAnimation: - deleteSections:withRowAnimation: - moveSection:toSection:
- scrollToRowAtIndexPath:atScrollPosition:animated: - scrollToNearestSelectedRowAtScrollPosition:animated:
答案 2 :(得分:0)
将这两种方法用于行移动
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath*)indexPath
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath