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;

        

        

    }

  • 相关阅读:
    微信第三方平台处理授权公众号的网页授权接口
    CentOS7配置图形界面及设置vnc远程连接、windows远程桌面连接
    CentOS7安装及配置vsftpd (FTP服务器)
    Asp.net Core发布到CentOS7
    MySQL常用命令整理
    CentOS7.0安装Nginx
    Android常用错误解决汇总
    C#调用百度云存储接口上传文件
    面试:实现二叉搜索树的查找、插入和删除操作
    面试:C++输入数据
  • 原文地址:https://www.cnblogs.com/guligei/p/3986060.html
Copyright © 2011-2022 走看看