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;

        

        

    }

  • 相关阅读:
    C/C++——二维数组与指针、指针数组、数组指针(行指针)、二级指针的用法
    C/C++——C语言数组名与指针
    C/C++——C语言跳出多重循环方法
    知识储备——国际象棋术语中英文对照
    C/C++——C语言库函数大全
    C/C++——C语言常用库函数
    C/C++——[05] 函数
    C/C++——[04] 语句
    C/C++——[03] 注释
    C/C++——[02] 运算符和表达式
  • 原文地址:https://www.cnblogs.com/guligei/p/3986060.html
Copyright © 2011-2022 走看看