我正在尝试使我的核心数据支持UITableView具有重新排序能力,在实现所有这些委托和一些技术为这里提到的核心数据后,我发现了奇怪的行为.点击编辑按钮后,重新排序图标显示就好了,我可以点击它,阴影显示,但当我尝试将其移动到其他行时,我突然失去焦点,细胞移回到它的位置.有谁知道这个问题的原因?
这是显示问题的视频
http://www.youtube.com/watch?v=ugxuLNL7BnU&feature=youtu.be
这是我的代码
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath
{
return YES;
}
Run Code Online (Sandbox Code Playgroud)
在-tableView:moveRowAtIndexPath:toIndexPath我尝试下面的代码,只是一个空的实现,但问题仍然存在,所以我不认为这不是一个问题.
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath
{
_changeIsUserDriven = YES;
NSUInteger fromIndex = sourceIndexPath.row;
NSUInteger toIndex = destinationIndexPath.row;
NSMutableArray *newsArray = [[self.fetchedResultsController fetchedObjects] mutableCopy];
News *news = [self.fetchedResultsController.fetchedObjects objectAtIndex:fromIndex];
[newsArray removeObject:news];
[newsArray insertObject:news atIndex:toIndex];
int i = 1;
for (News *n in newsArray) {
n.displayOrder = [NSNumber numberWithInt:i++];
}
[self saveContext];
_changeIsUserDriven = NO;
}
Run Code Online (Sandbox Code Playgroud)
FetchedResultController委托
- (void)controllerWillChangeContent:(NSFetchedResultsController *)controller …Run Code Online (Sandbox Code Playgroud)