iOS 使用UICollectionView实现瀑布流
来源:互联网 发布:mac黑屏问号文件夹闪烁 编辑:程序博客网 时间:2024/05/16 12:28
#pragma mark----UICollectionViewDataSource
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
returnself.itemData.count;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
//2列的瀑布流
MatchedCell *cell = [collectionViewdequeueReusableCellWithReuseIdentifier:@"MatchedCell"forIndexPath:indexPath];
//移除cell
// for (id subViews in cell.contentView.subviews) {
// [subViews removeFromSuperview];
// }
//当前列数
NSInteger remaineder = indexPath.row %2;
//当前行数
NSInteger currentRow = indexPath.row /2;
//取出单元格的高度
CGFloat currentHeight = [self.hArr[indexPath.row]floatValue] ;
//算出cell的x起始坐标
CGFloat positionX = (kScreenWidth /2 -8) * remaineder +5 * (remaineder +1);
//算出cell的y起始坐标
CGFloat positionY = (currentRow +1) *5;
for (int i =0; i < currentRow; i++) {
//遍历出此单元格之前所有的单元格下标,然后将其对应的高度相加,求出当前的高度
NSInteger position = remaineder + i *2;
positionY += [self.hArr[position]floatValue] ;
}
//从新定义单元格的位置与高度
cell.frame =CGRectMake(positionX,_matchedHeader.bottom -75 + positionY, kScreenWidth /2 -8, currentHeight);
// cell.backgroundColor = [UIColor redColor];
cell.itemModel =self.itemData[indexPath.row];
return cell;
}
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
returnCGSizeMake(kScreenWidth /2 - 8, [self.hArr[indexPath.row]floatValue]);
}
- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section
{
returnUIEdgeInsetsMake(0,0, -_edgHeight,0);
}
- iOS 使用UICollectionView实现瀑布流
- ios 应用UICollectionView实现瀑布流
- ios 应用UICollectionView实现瀑布流
- iOS UICollectionView实现瀑布流(3)
- iOS UICollectionView实现瀑布流(3)
- iOS开发-UICollectionView实现瀑布流
- iOS UICollectionView瀑布流
- 使用UICollectionView 重写UICollectionViewLayout实现瀑布流
- UICollectionView实现瀑布流
- iOS项目开发实战——使用UICollectionView实现瀑布流
- iOS开发之瀑布流的实现(UICollectionView与UIScrollView)
- [iOS高级] UICollectionView实现瀑布流效果
- [iOS高级] UICollectionView实现瀑布流效果
- IOS开发之瀑布流的实现(UICollectionView与UIScrollView)
- [iOS高级] UICollectionView实现瀑布流效果
- 用UICollectionView实现瀑布流
- UICollectionView的瀑布流实现
- IOS瀑布流通过UICollectionView控件实现
- ios:kvo概述
- 1>opencv_test1.obj : error LNK2019: 无法解析的外部符号_cvReleaseImage,该符号在函数_main 中被引用
- 为啥Android手机总会越用越慢?
- C# 获取本机IP MAC地址
- Java IO Stream 总结
- iOS 使用UICollectionView实现瀑布流
- 多线程之同步死锁
- java DataInputStream 和 DataOutputStream将基本类型数据写入文件
- HDU 2824 The Euler function(筛法求欧拉phi函数)
- 一步一步学jQuery(七)
- java中的Volatile变量
- HDU 3374 String Problem(最小表示法·KMP)
- 神经网络(Neural Network)概述
- 分治算法(思想)在数据结构中的应用