好的,所以我添加了一张正在发生的事情的图片,这可能有助于更好地可视化问题。
因此,一旦我单击“购物和交易”部分图像,就会下拉项目或单元格列表;但是,如您所见,仍然有一些单元格隐藏在“Shopping & Deals”图像下。现在这里是代码:
- (void) sectionOpened : (NSInteger) section{
SectionInfo *array = [self.sectionInfoArray objectAtIndex:section];
array.open = YES;
//Google PageView tracker
self.trackedViewName = [NSString stringWithFormat:@"Find Things To Do -- %@",array.category.name];
//Mobile Apptracking track event
[[MobileAppTracker sharedManager] trackActionForEventIdOrName:[NSString stringWithFormat:@"Find Things To Do -- %@",array.category.name] eventIsId:NO];
NSInteger count = [array.category.list count];
NSMutableArray *indexPathToInsert = [[NSMutableArray alloc] init];
for (NSInteger i = 0; i<count;i++)
{
[indexPathToInsert addObject:[NSIndexPath indexPathForRow:i inSection:section]];
}
NSMutableArray *indexPathsToDelete = [[NSMutableArray alloc] init];
NSInteger previousOpenIndex = self.openSectionIndex;
if (previousOpenIndex != NSNotFound)
{
SectionInfo *sectionArray = [self.sectionInfoArray objectAtIndex:previousOpenIndex];
sectionArray.open = NO;
NSInteger counts = [sectionArray.category.list count];
[sectionArray.sectionView toggleButtonPressed:FALSE];
for (NSInteger i = 0; i<counts; i++)
{
[indexPathsToDelete addObject:[NSIndexPath indexPathForRow:i inSection:previousOpenIndex]];
}
}
UITableViewRowAnimation insertAnimation;
UITableViewRowAnimation deleteAnimation;
if (previousOpenIndex == NSNotFound || section < previousOpenIndex)
{
insertAnimation = UITableViewRowAnimationTop;
deleteAnimation = UITableViewRowAnimationBottom;
}
else
{
insertAnimation = UITableViewRowAnimationBottom;
deleteAnimation = UITableViewRowAnimationTop;
}
[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;
}
现在,如果您查看代码的底部,则有:
[atableView setContentOffset:CGPointMake(0, self.view.bounds.size.height)];
这会根据 y 边界偏移视图。这样做的原因是,如果您查看图片,一旦我单击“生产力”部分,单元格就会下拉到视图之外,您无法判断是否有任何单元格实际填充,因此偏移内容会推动视图起来,这样那些细胞就会出现。现在的问题是,一旦我点击“购物和交易”,这些单元格就会挂在该部分的下方。有人对如何解决这个问题有任何想法吗?