1

我有一段扩展部分单元格行的代码。错误发生在 xtable 更新 [ UIViewAnimation initWithView:indexPath:endRect:endAlpha:startFraction:endFraction:curve:animateFromCurrentPosition:shouldDeleteAfterAnimation:editing:]

代码片段

  -(void)sectionHeaderView:(SectionHeaderView*)sectionHeaderView sectionOpened:(NSInteger)sectionOpened {


SectionInfo *sectionInfo = [self.sectionInfoArray objectAtIndex:sectionOpened];

sectionInfo.open = YES;



    NSInteger countOfRowsToInsert = 5;         
NSMutableArray *indexPathsToInsert = [[NSMutableArray alloc] init];
for (NSInteger i = 0; i < countOfRowsToInsert; i++) {
    [indexPathsToInsert addObject:[NSIndexPath indexPathForRow:i inSection:sectionOpened]];
}


NSMutableArray *indexPathsToDelete = [[NSMutableArray alloc] init];

NSInteger previousOpenSectionIndex = self.openSectionIndex;
if (previousOpenSectionIndex != NSNotFound) {

    SectionInfo *previousOpenSection = [self.sectionInfoArray objectAtIndex:previousOpenSectionIndex];
    previousOpenSection.open = NO;
    [previousOpenSection.headerView toggleOpenWithUserAction:NO];
    NSInteger countOfRowsToDelete = 5;    

    for (NSInteger i = 0; i < countOfRowsToDelete; i++) {
        [indexPathsToDelete addObject:[NSIndexPath indexPathForRow:i inSection:previousOpenSectionIndex]];
    }
}

// Style the animation so that there's a smooth flow in either direction.
UITableViewRowAnimation insertAnimation;
UITableViewRowAnimation deleteAnimation;
if (previousOpenSectionIndex == NSNotFound || sectionOpened < previousOpenSectionIndex) {
    insertAnimation = UITableViewRowAnimationTop;
    deleteAnimation =UITableViewRowAnimationBottom;
}
else {
    insertAnimation = UITableViewRowAnimationBottom;
    deleteAnimation = UITableViewRowAnimationTop;
}

// Apply the updates.
[xtable beginUpdates];
[xtable insertRowsAtIndexPaths:indexPathsToInsert withRowAnimation:insertAnimation];


 [xtable deleteRowsAtIndexPaths:indexPathsToDelete withRowAnimation:deleteAnimation];
[xtable  endUpdates];
self.openSectionIndex = sectionOpened;

}

有什么可能是错的?有任何想法吗?

4

1 回答 1

0

在我的情况下帮助

-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
return 0;
}
于 2015-12-25T13:36:33.733 回答