呜呜 写的代码被弃用了 放到这里 留个纪念

来源:互联网 发布:飞狐软件官网 编辑:程序博客网 时间:2024/06/07 09:40

//制作cell行高

- (void)calCellHeight

{

    for (int i = 0;i < _displayPictureArray.count;i++)

    {

        CGFloat firstColHeight = PERSONAL_PICFLOW_GAP;

        CGFloat secondColHeight = PERSONAL_PICFLOW_GAP;

        //cell的布局设置

        CellLayoutSetting * cellLayoutSetting = [[CellLayoutSetting alloc] init];

        PersonalPicDisplayData * tmpPicDisplayData = [_displayPictureArray objectAtIndex:i];

        for (int j = 0; j < [tmpPicDisplayData.displayPicArray count]; j++)

        {

            

            SmallPictureData * tmpPictureData  = [tmpPicDisplayData.displayPicArray objectAtIndex:j];

            //测试用模拟数据

            tmpPictureData.smallPicHeight = arc4random() % 60 + 40;

            tmpPictureData.smallPicWidth = arc4random() % 40 + 40;

            

            //根据比例计算要显示的高度

            CGFloat perPicHeight = tmpPictureData.smallPicHeight * PERSONAL_PICFLOW_WIDTH *(1.0f) / tmpPictureData.smallPicWidth;

            //测试用模拟数据

            [cellLayoutSetting.picHeightInCell addObject:[NSString stringWithFormat:@"%f",perPicHeight]];

            NSLog(@"%@",cellLayoutSetting.picHeightInCell);

            if(j == 0)

            {

                firstColHeight = perPicHeight + PERSONAL_PICFLOW_GAP;

            }

            else

            {

                if (firstColHeight < secondColHeight)

                {

                    firstColHeight = firstColHeight + perPicHeight + PERSONAL_PICFLOW_GAP;

                }

                else

                {

                    secondColHeight = secondColHeight + perPicHeight + PERSONAL_PICFLOW_GAP;

                }

            }

        }

        cellLayoutSetting.cellHeight = (firstColHeight > secondColHeight) ? firstColHeight:secondColHeight;

        //保存每个cell的高度及其内部所有图片的尺寸大小

        [picPageLayoutSetting addObject:cellLayoutSetting];

        [cellLayoutSetting release];

    }

    //同步数据之后 dateTableView开始重新进行加载

    [self.dateTableView reloadData];

}


//makeCell atIndex

 PicFlowColArray * firstColArray = [[PicFlowColArray alloc] init];

    PicFlowColArray * secondColArray = [[PicFlowColArray alloc] init];

    firstColArray.originY = PERSONAL_PICFLOW_GAP;

    secondColArray.originY = PERSONAL_PICFLOW_GAP;

    for (int i = 0; i < [cellLayoutSetting.picHeightInCell count];i++)

    {

        CGFloat height = [[cellLayoutSetting.picHeightInCell objectAtIndex:i] floatValue];

        if(i == 0)

        {

            UIImageView * iv = [[UIImageView alloc] initWithFrame:CGRectMake(PERSONAL_DATE_WIDTH + PERSONAL_PICFLOW_GAP, PERSONAL_PICFLOW_GAP, PERSONAL_PICFLOW_WIDTH, height)];

            iv.backgroundColor = [UIColor yellowColor];

            firstColArray.originY = firstColArray.originY + height + PERSONAL_PICFLOW_GAP;

            [tmpCell addSubview:iv];

            [iv release];

        }

        else

        {

            if (firstColArray.originY > secondColArray.originY)

            {

                UIImageView * iv = [[UIImageView alloc] initWithFrame:CGRectMake(PERSONAL_DATE_WIDTH + PERSONAL_PICFLOW_GAP * 2 + PERSONAL_PICFLOW_WIDTH, secondColArray.originY, PERSONAL_PICFLOW_WIDTH, height)];

                iv.backgroundColor = [UIColor yellowColor];

                secondColArray.originY = secondColArray.originY + height +PERSONAL_PICFLOW_GAP;

                [tmpCell addSubview:iv];

                [iv release];

            }

            else

            {

                UIImageView * iv = [[UIImageView alloc] initWithFrame:CGRectMake(PERSONAL_DATE_WIDTH + PERSONAL_PICFLOW_GAP, firstColArray.originY, PERSONAL_PICFLOW_WIDTH, height)];

                iv.backgroundColor = [UIColor yellowColor];

                firstColArray.originY = firstColArray.originY + height +PERSONAL_PICFLOW_GAP;

                [tmpCell addSubview:iv];

                [iv release];

            }

        }

    }

    [firstColArray release];

    [secondColArray release];



原创粉丝点击