【问题标题】:moveRowAtIndexPath without Delete buttonmoveRowAtIndexPath 没有删除按钮
【发布时间】:2014-03-31 13:47:46
【问题描述】:
我需要UITableview 的帮助,特别是- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath。
如果我设置[tableView setEditing:YES animated:YES];,则表包含删除和移动单元功能。但我只需要 moveCell 功能。我不想要删除类别。
这样,
有没有办法做到这一点?
感谢帮助。
【问题讨论】:
标签:
ios
iphone
objective-c
uitableview
【解决方案1】:
只需使用此方法,使单元格没有编辑控件:
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
return UITableViewCellEditingStyleNone;
}
为了不让指定行的背景缩进:
- (BOOL)tableView:(UITableView *)tableview shouldIndentWhileEditingRowAtIndexPath:(NSIndexPath *)indexPath {
return NO;
}
这样行可以移动:
-(BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
return YES;
}