-(IBAction)stretchAction:(NSUInteger)section
{
if (self.beforeIndex != -1 && self.beforeIndex != section) {
GoodsInfo *mInfo = [self.dataArray objectAtIndex:self.beforeIndex];
if (mInfo.isOpen) {
mInfo.isOpen = !mInfo.isOpen;
NSMutableArray* rowToInsert = [[NSMutableArray alloc] init];
for (NSUInteger i = 1; i < mInfo.ChildrenCategrys.count+1; i++) {
NSIndexPath* indexPathToInsert = [NSIndexPath indexPathForRow:i inSection:self.beforeIndex];
[rowToInsert addObject:indexPathToInsert];
}
[self.tableView beginUpdates];
[self.tableView deleteRowsAtIndexPaths:rowToInsert withRowAnimation:UITableViewRowAnimationTop];
[self.tableView endUpdates];
}
}
GoodsInfo *info = [self.dataArray objectAtIndex:section];
info.isOpen = !info.isOpen;
NSMutableArray* rowToInsert = [[NSMutableArray alloc] init];
for (NSUInteger i = 1; i < info.ChildrenCategrys.count+1; i++) {
NSIndexPath* indexPathToInsert = [NSIndexPath indexPathForRow:i inSection:section];
[rowToInsert addObject:indexPathToInsert];
}
[self.tableView beginUpdates];
if (info.isOpen) {
[self.tableView insertRowsAtIndexPaths:rowToInsert withRowAnimation:UITableViewRowAnimationTop];
}else{
[self.tableView deleteRowsAtIndexPaths:rowToInsert withRowAnimation:UITableViewRowAnimationTop];
}
[self.tableView endUpdates];
[self.tableView beginUpdates];
NSIndexPath *path = [NSIndexPath indexPathForRow:0 inSection:section];
[self.tableView scrollToRowAtIndexPath:path atScrollPosition:UITableViewScrollPositionTop animated:YES];
[self.tableView endUpdates];
self.beforeIndex = section;
}