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;

        

        

    }

  • 相关阅读:
    springcloud 使用feign
    Could not resolve placeholder ‘xxx‘ in value “${xxx}“
    小程序中腾讯位置服务的使用/小程序中使用腾讯服务获取位置信息
    h5页面节假日置灰
    form表单提交入参唤起支付
    小程序中下拉框组件
    Android实践项目汇报(四)
    WORD表格数据运算技巧
    路由器桥接(WIFI无线中继)设置及摆放位置图解
    批处理设置IP地址
  • 原文地址:https://www.cnblogs.com/guligei/p/3986060.html
Copyright © 2011-2022 走看看