moveRowAtIndexPath没有删除按钮

时间:2014-03-31 13:47:46

标签: ios iphone objective-c uitableview

我需要UITableview具体- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath的帮助。

在此我设置[tableView setEditing:YES animated:YES];然后表包含delete和moveCell功能。但我只需要moveCell功能。我不想要删除类别。

像这样,

Tableview cell without delete button while Editing

有没有办法做到这一点? 帮助者很感激。

1 个答案:

答案 0 :(得分:2)

只需使用此方法,以便单元格没有编辑控件:

- (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;
 }