非常非常基本。我不明白。当表格加载时以及切换编辑时canEdit
被调用,而不是canMove
。我做错了什么?
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"canEdit=%d", indexPath.row);
// output is as expected, "canEdit" for each row
return (indexPath.section == 1) ? YES : NO;
}
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"canMove=%d", indexPath.row);
// nothing. No output
return (indexPath.section == 1) ? YES : NO;
}
谢谢!
答案 0 :(得分:13)
对不起,问题在这里得到解答:
Reorder control isn't displayed on table view
您还必须实施
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath
<强>夫特强>:
func tableView(_ tableView: UITableView, canMoveRowAt indexPath: IndexPath) -> Bool {
return true
}
func tableView(_ tableView: UITableView, moveRowAt sourceIndexPath: IndexPath, to destinationIndexPath: IndexPath) {
//code
}