好的,所以我添加了一张正在发生的事情的图片,这可能有助于更好地理解问题。
因此,一旦我点击“购物和优惠”部分图片,项目或单元格列表就会下拉;但是,正如您所看到的,仍有一些细胞隐藏在“购物和交易”图像下。现在这里是代码:
- (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边界偏移视图。这样做的原因是,如果你看一下图片,一旦我点击“生产力”部分,单元格就会从视图中下拉,你无法判断是否有任何单元格实际填充过,因此偏移内容会推动视图以便那些细胞出现。现在的问题是,一旦我点击“购物和促销”,单元格就会悬挂在该部分下面。有没有人对如何解决这个问题有任何想法?