Iphone canMoveRowAtIndexPath不';不会被呼叫-但CaneditRowatineXpath会
非常非常基本。我不明白。加载表格和切换编辑时,调用Iphone canMoveRowAtIndexPath不';不会被呼叫-但CaneditRowatineXpath会,iphone,ios,uitableview,Iphone,Ios,Uitableview,非常非常基本。我不明白。加载表格和切换编辑时,调用canEdit,但不调用canMove。我做错了什么 - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath { NSLog(@"canEdit=%d", indexPath.row); // output is as expected, "canEdit" for each row return (inde
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;
}
谢谢 对不起,这里回答了这个问题: 您还必须实现
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath
Swift:
func tableView(_ tableView: UITableView, canMoveRowAt indexPath: IndexPath) -> Bool {
return true
}
func tableView(_ tableView: UITableView, moveRowAt sourceIndexPath: IndexPath, to destinationIndexPath: IndexPath) {
//code
}
表中总共有多少节?这应该是-(void)tableView:(UITableView*)tableView MoveRowatineXpath:(NSIndexPath*)sourceIndexPath to IndeXpath:(NSIndexPath*)DestinationIndepath我已经实现了这两个Swift方法,并且canMoveRowAt为每个可能的执行路径打印一条消息。进入编辑模式时,将引用所有单元格,并为每个单元格打印一条消息,但在执行移动并上下滚动视图以刷新视图后,调试输出显示只有部分单元格(而不是全部单元格)被迭代。