3

看看这个视频

运行此代码时出现此故障:

[NSFetchedResultsController deleteCacheWithName:@"Root"];
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"following == YES"];
[self.fetchedResultsController.fetchRequ­est setPredicate:predicate];
[self.fetchedResultsController performFetch:nil];
[self.tableView beginUpdates];
[self.tableView reloadSections:[NSIndexSet indexSetWithIndex:THE_SECTION_WITH_THE_B­LOGS] withRowAnimation:UITableViewRowAnimation­Automatic];
[self.tableView endUpdates];

为什么我重新加载的部分下方的部分标题会像这样改变它的框架?有什么解决办法吗?

编辑:

这是我的 viewForHeaderInSection:

(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
if (tableView != self.tableView)
return nil;
BLMenuTableSectionHeaderView *view = nil;

if (section != BLMenuSectionUser) {
    view = [[BLMenuTableSectionHeaderView alloc] initWithFrame:CGRectZero];
    if (section == BLMenuSectionFollowing){
        if ([self blogCount] > 0){
            [view setTitle:NSLocalizedString(@"Following", nil)];
            [view addSubview:self.editButton];
        }else{
            self.tableView.editing = NO;
        }
    }
    if (section == BLMenuSectionPosts){
        [view setTitle:NSLocalizedString(@"Browse", nil)];
    }
    else if (section == BLMenuSectionSettings)
        [view setTitle:NSLocalizedString(@"Settings", nil)];
}

return view;
}
4

1 回答 1

0

Afaik,您不应将-beginUpdatesand-endUpdatesreload结合使用,而应在插入或删除时使用。

不确定这是否会导致您的问题,但可能值得一试。

无论动画类型如何,都一样吗?

来自Apple 的文档

如果您希望后续的插入、删除和选择操作(例如,cellForRowAtIndexPath: 和 indexPathsForVisibleRows)同时进行动画处理,请调用此方法。这组方法必须以调用 endUpdates 结束。这些方法对可以嵌套。如果您不在此块内进行插入、删除和选择调用,则行数等表属性可能会变得无效。你不应该在组内调用 reloadData;如果您在组内调用此方法,您将需要自己执行任何动画

于 2013-05-23T19:52:42.650 回答