uitableview 重新排序不起作用,源始终等于目标 [英] uitableview re-order won't work, source always equal to destination
问题描述
我有一个不会重新排序的tableview.看起来 moveRowAtIndexPath 从未使用与 destinationIndexPath 不同的 sourceIndexPath 调用.当我拉一排时,它会弹回到起始位置,就好像该排不支持移动一样.
I have a tableview that won't reorder. It looks like moveRowAtIndexPath is never called with a sourceIndexPath that is different from the destinationIndexPath. When I pull a row, it bounces back to its starting location as if the row didn't support movement.
我尝试实现所有canMove/canEdit/propose"方法以返回 YES,但我观察到相同的行为.怎么回事?
I tried implementing all the "canMove/canEdit/propose" methods to return YES, but I observe the same behavior. What's going on?
- (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,它取消了视图中的平移.
I'm using IIViewDeckController, which cancels panning in views.
设置 ViewDeckController 时,请执行以下操作:self.panningCancelsTouchesInView = NO;
When setting up the ViewDeckController, do this: self.panningCancelsTouchesInView = NO;
这篇关于uitableview 重新排序不起作用,源始终等于目标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!