Iwo*_*row 5 ios uicollectionview
我有问题UICollectionView.问题是,在我的单元格高度动态后(静态高度没有出现问题),经过一段时间后,当数据发生变化时(我正在添加或替换单元格并调用[self.collectionView reloadData];),单元格就停止显示/消失(开始时,单元格始终正确显示).对于相同的内容,这种情况随机发生,有时更早,有时甚至更晚.滚动存在,整个事物的高度似乎反映了单元格的高度,也sizeForItemAtIndexPath被调用,并返回正确的值(所以是numberOfItemsInSection和numberOfSectionsInCollectionView),但cellForItemAtIndexPath停止被调用.内容消失后 - 无论我尝试显示什么数据(即使显示没有问题的初始数据),UICollectionView也不会显示任何单元格.值得一提的是,我调用的内容[self.collectionView reloadData];非常多,因为我懒得加载图像,并在每个图像加载后刷新集合视图.
在我的UICollectionViewController中我有:
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
float height = 0.0f;
CGSize retval;
...
height = [T20UploadMessageCell getImageHeight:m.upload];
retval = CGSizeMake(self.view.frame.size.width, height);
...
return retval;
}
Run Code Online (Sandbox Code Playgroud)
在T20UploadMessageCell.m中
+(float)getImageWidth:(Upload*)upload{
return 98.0f;
}
+(float)getImageHeight:(Upload*)upload{
if (upload.isLoaded)
return 42.0f + upload.height * ([T20UploadMessageCell getImageWidth:upload]/upload.width);
else return 140.0f;
}
Run Code Online (Sandbox Code Playgroud)
我试过添加
-(BOOL)shouldInvalidateLayoutForBoundsChange:(CGRect)newBounds
{
return YES;
}
Run Code Online (Sandbox Code Playgroud)
在我的布局中,但这并没有帮助我知道这可能发生在高大的细胞,但我不认为这是这种情况,因为最大高度是385,也尝试限制它,也作为我之前提到的 - 对于相同的细胞,这可能发生与否 - 它只是随机的.将会感谢你的帮助.谢谢
| 归档时间: |
|
| 查看次数: |
776 次 |
| 最近记录: |