您的位置:首页 > 编程语言

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

2013-01-10 11:58 162 查看
//制作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];
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐