Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/105.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/oracle/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 设置动画后,UITableview单元将隐藏在剖面下。_Ios_Objective C_Uitableview - Fatal编程技术网

Ios 设置动画后,UITableview单元将隐藏在剖面下。

Ios 设置动画后,UITableview单元将隐藏在剖面下。,ios,objective-c,uitableview,Ios,Objective C,Uitableview,所以我有一个包含3个不同部分的tableview,一旦你点击其中一个部分,一组单元格就会从该部分中下拉下来。现在我试图让表格视图滚动到每个部分的最后一个单元格。到目前为止,我已经想到了这一点: [atableView beginUpdates]; [atableView insertRowsAtIndexPaths:indexPathToInsert withRowAnimation:insertAnimation]; [atableView setContentOffset:

所以我有一个包含3个不同部分的tableview,一旦你点击其中一个部分,一组单元格就会从该部分中下拉下来。现在我试图让表格视图滚动到每个部分的最后一个单元格。到目前为止,我已经想到了这一点:

[atableView beginUpdates];

    [atableView insertRowsAtIndexPaths:indexPathToInsert withRowAnimation:insertAnimation];
    [atableView setContentOffset:CGPointMake(0, self.view.bounds.size.height)];
    [atableView deleteRowsAtIndexPaths:indexPathsToDelete withRowAnimation:deleteAnimation];

    [atableView endUpdates];

   self.openSectionIndex = section;

因此,当我使用这种方法时,它会像我想要的那样向上移动整个视图,但是一些顶部的单元格会被切断并隐藏在它们从中掉落的部分下面。我可能调用这个方法太早了,它是在行完成动画制作之前调用的,或者它们是在节下反弹回来的。我可以在桌面视图上向下拉,然后单元格从剖面下面出来。有什么想法吗?

我实现了一个可折叠的部分组件,就像您所描述的,可能有一个解决方案

我的实现在图书馆里。尝试运行折叠示例项目。展开第一部分。然后展开该部分。您将看到,当单元格设置动画时,表格滚动以在屏幕上显示尽可能多的部分

做到这一点的诀窍是认识到您需要滚动到一个不一定存在的位置,因为表视图直到过程的稍后一段时间才重新计算其内容大小。我使用的解决方案是将表视图的contentSize显式设置为包含要滚动到的位置的值。我在中的实现如下所示:

/*
 Force table to scroll to the specified location even if it is beyond the current
 content area. Use this to scroll to a future location during animiated table updates
 with the assumption that the location will be valid after the updates.
 */
- (void)forceTableScrollBasedOnExpectedSize:(CGFloat)scrollLocation animated:(BOOL)animated
{
    CGSize expectedMinimumContentSize = self.tableView.contentSize;
    if (expectedMinimumContentSize.height < scrollLocation) {
        // Temporarily expand the content area to contain the scroll location.
        // The table will overwrite this during the update process.
        expectedMinimumContentSize.height = scrollLocation;
        self.tableView.contentSize = expectedMinimumContentSize;
    }
    [self.tableView scrollRectToVisible:CGRectMake(0, scrollLocation-1, 1, 1) animated:animated];
}
其中scrollLocation是要使其可见的最底部位置。您可以看到在中如何使用此功能的更多详细信息


我不确定这是否适用于你的问题。如果没有,请在您的问题中详细说明。

单元格的默认行为是放在节下面。是的,这完全有道理,因为我无法设置特定的滚动位置,因为我尝试使用[atableView ScrollToRowatineXpath:[NSIndexPath indexPathForItem:0第0节:0]atScrollPosition:UITableViewRowAnimationBottom animated:YES];它不断产生错误。我想这可能会引导我走向正确的方向,但我现在的代码可以满足我的需要,除了一个小细节。我想我应该详细阐述一下,但基本上问题是从我的表视图行超出视图或屏幕开始的。因此,我认为,一旦主节标题“what selected”(所选内容)偏移视图,就可以部分解决问题。所以这才是真正的问题所在。