我有一个UITableView
,允许用户在其中对单元格进行重新排序。所有单元格都可以重新排序,但顶行除外,它必须始终保留为顶行。
我使用了canMoveRowAtIndexPath
方法来防止顶行被移动。但是,我看不到一种方法来防止用户拖动其他行并将它们放在顶行之上,从而违反了我的顶行要求。
如何阻止用户将其他行拖动到顶行之上?
谢谢。
发布于 2012-06-29 19:15:33
如果目标索引路径不满足您的要求,可以使用UITableViewDelegate方法修改目标索引路径。我认为这应该行得通:
- (NSIndexPath *)tableView:(UITableView *)tableView targetIndexPathForMoveFromRowAtIndexPath:(NSIndexPath *)sourceIndexPath toProposedIndexPath:(NSIndexPath *)proposedDestinationIndexPath {
if (proposedDestinationIndexPath.row == 0) {
return sourceIndexPath;
}
else {
return proposedDestinationPath;
}
}
https://stackoverflow.com/questions/11260617
复制相似问题