objective-c - 无法将表格重新排序才能正常工作

标签 objective-c ios uitableview

从UITableViewCell showsReorderControl文档:

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
}

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

但是我看不到重新排序控件,我想念什么?

最佳答案

您是否通过以下方式将UITableView置于编辑模式

[tableView setEditing:YES animated:YES];



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

关于objective-c - 无法将表格重新排序才能正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10934739/

相关文章:

objective-c - NSScrollView:使用 CMD+滚动交互进行放大,并保留响应式滚动

objective-c - [NSDate distancePant] 返回的错误指针

ios - Swift:对数字字符串字典进行排序

ios - UITableViewCell 中的多行 UILabel 在 iOS8 中使用 autoLayout 给出错误的高度

ios - 获取 NSGenericException 原因为 : '*** Collection <NSConcreteHashTable: 0x282c34140> was mutated while being enumerated.'

iOS - 逐帧读取视频文件,图像处理,然后另存为新视频文件

ios - 如何使用警报 View 刷新 uitableivew?

ios - 如何顺利地允许在我的聊天应用程序中发送消息?

ios - Cloudkit 获取非常慢

iphone - 录音机中的音频表