ios - uitableview 重新排序不起作用,源始终等于目标

标签 ios objective-c uitableview

我有一个不会重新排序的表格 View 。看起来从未使用与 destinationIndexPath 不同的 sourceIndexPath 调用 moveRowAtIndexPath。当我拉动一行时,它会弹回其起始位置,就好像该行不支持移动一样。

我尝试实现所有“canMove/canEdit/propose”方法以返回"is",但我观察到相同的行为。怎么回事?

- (void) tableView:(UITableView *)tableView
moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath
       toIndexPath:(NSIndexPath *)destinationIndexPath {

    NSLog(@"%d -> %d", [sourceIndexPath row], [destinationIndexPath row]);
    if ([sourceIndexPath row] == [destinationIndexPath row]) {
        return;
    }

    MyDomain *domain = [self getObject];
    [domain.stuff exchangeObjectAtIndex:(NSUInteger) [sourceIndexPath row] withObjectAtIndex:(NSUInteger) [destinationIndexPath row]];
}

最佳答案

我正在使用 IIViewDeckController,它取消了 View 中的平移。

设置 ViewDeckController 时,请执行以下操作: self.panningCancelsTouchesInView = NO;

关于ios - uitableview 重新排序不起作用,源始终等于目标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16628615/

相关文章:

ios - UITableView 自定义单元格不刷新

ios - 无法在iOS8中使用社交框架设置联系人图像

iphone - 获取国家域名代码

swift - 为什么我的父类(super class)在 Swift 中调用子类的方法而不是它自己的方法?

iphone - ScrollView 仅在 View 出现第二次时才开始滚动

ios - 添加 Xcode 子项目 : Shouldn't all the source files get copied?

iphone - NSDictionary - 如何将键作为字符串返回

ios - 核心数据使用一对多关系保存记录?

uitableview - 在 iOS7 中将搜索栏与导航栏相结合时,会清空 UISearchbar 空间吗?

ios - 给定 UITableViewCell 的 indexPath,加载该特定单元格