endUpdates之后的UITableView部分页脚视图位置 [英] UITableView section footer view position after endUpdates

查看:149
本文介绍了endUpdates之后的UITableView部分页脚视图位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在ios8上,我正在使用核心数据表视图控制器,删除行后,我的部分页脚视图突然一直向下到 UITableView 的底部。当我滚动表格视图时,页脚视图会回到它的位置。如何解决这个问题以及为什么会发生这种情况?

On ios8 I'm using core data table view controller, and after deleting rows my section footer view suddenly goes all the way down to the bottom of the UITableView. When I scroll the table view, footer view goes back to its place. How can fix this and why is this happening?

以下是代码以防万一。

- (void)controller:(NSFetchedResultsController *)controller
   didChangeObject:(id)anObject
       atIndexPath:(NSIndexPath *)indexPath
     forChangeType:(NSFetchedResultsChangeType)type
      newIndexPath:(NSIndexPath *)newIndexPath
{       
    if (!self.suspendAutomaticTrackingOfChangesInManagedObjectContext)
    {
        switch(type)
        {
            case NSFetchedResultsChangeInsert:
                [self.tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:newIndexPath] withRowAnimation:UITableViewRowAnimationFade];
                break;

            case NSFetchedResultsChangeDelete:
                [self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationNone];
                break;

            case NSFetchedResultsChangeUpdate:
                [self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
                break;

            case NSFetchedResultsChangeMove:
                [self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
                [self.tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:newIndexPath] withRowAnimation:UITableViewRowAnimationFade];
                break;
        }
    }
}

- (void)controllerDidChangeContent:(NSFetchedResultsController *)controller
{
    if (self.beganUpdates)
    {
       [self.tableView endUpdates];
    }
}


推荐答案

这是一个iOS 8动画更改。您必须将tableview样式更改为分组,以防止部分页脚移动到uitableview的引导程序

This is an iOS 8 animation change. You must change your tableview style to 'grouped' in order to keep the section footer from moving to the bootom of the uitableview

这篇关于endUpdates之后的UITableView部分页脚视图位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆