QQ列表的收缩展开,带动画效果

来源:互联网 发布:python数据分析 微盘 编辑:程序博客网 时间:2024/04/28 14:06

-(void)sectionHeaderView:(QQSectionHeaderView*)sectionHeaderView sectionClosed:(NSInteger)section

{

QQList *persons = [listsobjectAtIndex:section];

persons.opened = !persons.opened;

// 收缩+动画 (如果不需要动画直接reloaddata)

NSInteger countOfRowsToDelete = [self.tableViewnumberOfRowsInSection:section];

    if (countOfRowsToDelete > 0) {

        persons.indexPaths = [[NSMutableArrayalloc] init];

        for (NSInteger i = 0; i < countOfRowsToDelete; i++) {

            [persons.indexPathsaddObject:[NSIndexPath indexPathForRow:iinSection:section]];

        }

        [self.tableViewdeleteRowsAtIndexPaths:persons.indexPathswithRowAnimation:UITableViewRowAnimationTop];

    }

}


-(void)sectionHeaderView:(QQSectionHeaderView*)sectionHeaderView sectionOpened:(NSInteger)section

{

QQList *persons = [listsobjectAtIndex:section];

persons.opened = !persons.opened;

// 展开+动画 (如果不需要动画直接reloaddata)

if(persons.indexPaths){

[self.tableViewinsertRowsAtIndexPaths:persons.indexPathswithRowAnimation:UITableViewRowAnimationBottom];

}

persons.indexPaths = nil;

}

原创粉丝点击