1

从 UITableViewCell 显示ReorderControl 文档:

For the reordering control to appear, you must not only set this property but implement the UITableViewDataSource method tableView:moveRowAtIndexPath:toIndexPath:. In addition, if the data source implements tableView:canMoveRowAtIndexPath: to return NO, the reordering control does not appear in that designated row.

我的 tableviewController 中都有这两个:

- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
    return YES;
}

- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
    NSLog(@"move from:%d to:%d", fromIndexPath.row, toIndexPath.row);
   //just for test
}

我的单元格属性,包括重新排序控件:

在此处输入图像描述

但是我看不到重新订购控制,我错过了什么?

4

2 回答 2

2

你有没有通过你的 UITableView 进入编辑模式

[tableView setEditing:YES animated:YES];

?

顺便说一句,您发布的第一种方法是不必要的,因为这是默认行为。

于 2012-06-07T15:26:56.147 回答
2

我认为您实际上需要进入表格的编辑模式。当您的视图出现时在代码中尝试它,或者创建一个可以执行此操作的按钮。

[tableView setEditing:YES animated:YES];
于 2012-06-07T15:27:09.703 回答