zoukankan      html  css  js  c++  java
  • tbsections,

    -(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;

        

        

    }

  • 相关阅读:
    [Codeforces967C]Stairs and Elevators(二分查找)
    [Codeforces976E]Well played!(贪心)
    [USACO12JAN]视频游戏的连击Video Game Combos(AC自动机+DP)
    [HDU2222]Keywords Search(AC自动机)
    [BZOJ1030][JSOI2007]文本生成器(AC自动机+DP)
    基于ZooKeeper实现——分布式锁与实现
    基于Redis实现——分布式锁与实现
    java 接口请求返回通用json
    Java SHAA加密
    (转)一些牛人榜样,多看看他们写的东西(后续整理牛人的blog等)
  • 原文地址:https://www.cnblogs.com/guligei/p/3986060.html
Copyright © 2011-2022 走看看