where amazing happens

- (void)didSelectCellRowFirstDo:(BOOL)firstDoInsert nextDo:(BOOL)nextDoInsert

{

    self.isOpen = firstDoInsert;

    

    FlightListCell *cell1 = (FlightListCell *)[self.expansionTableViewcellForRowAtIndexPath:self.selectIndex];

    if (self.isOpen) {

        cell1.flightBottomLineImageView.hidden = YES;

        

    }else{

        cell1.flightBottomLineImageView.hidden = NO;

    }

   

    //FlightListCell *cell = (FlightListCell *)[self.expansionTableView cellForRowAtIndexPath:self.selectIndex];

    [self.expansionTableViewbeginUpdates];

    

    int section = self.selectIndex.section;

     HFFlight *flight  = (HFFlight *)[self.fListArray objectAtIndex:section];

    if (firstDoInsert && !nextDoInsert) {

        

        

        if (flight.tempCabins) {// 缓存中加载数据

            flight.cabins = flight.tempCabins;

            [self.expansionTableViewreloadData];

 

        }else{

            [self loadCabins:flight];

 

        }

    }

   

    int contentCount = flight.cabins.count;

NSMutableArray* rowToInsert = [[NSMutableArrayalloc] init];

for (NSUInteger i = 1; i < contentCount + 1; i++) {

NSIndexPath* indexPathToInsert = [NSIndexPath indexPathForRow:i inSection:section];

[rowToInsert addObject:indexPathToInsert];

}

 

if (firstDoInsert)

        

    {

              [self.expansionTableViewinsertRowsAtIndexPaths:rowToInsert withRowAnimation:UITableViewRowAnimationTop];

    }

else

    {

        [self.expansionTableViewdeleteRowsAtIndexPaths:rowToInsert withRowAnimation:UITableViewRowAnimationTop];

    }

    

[self.expansionTableViewendUpdates];

    if (nextDoInsert) {

        self.isOpen = YES;

        self.selectIndex = currentIndexPath;

 

       // self.selectIndex = [self.expansionTableView indexPathForSelectedRow];

        [selfdidSelectCellRowFirstDo:YESnextDo:NO];

    }

    if (self.isOpen) {

        [self.expansionTableViewscrollToRowAtIndexPath:currentIndexPathatScrollPosition:UITableViewScrollPositionTopanimated:YES];

       // [self.expansionTableView scrollsToTop];

    }

    //if (self.isOpen) [self.expansionTableView scrollToNearestSelectedRowAtScrollPosition:UITableViewScrollPositionTop animated:YES];

}

原文地址:https://www.cnblogs.com/guligei/p/3095359.html