我有流布局的UICollectionView,并根据我的需要它的细胞varing大小,所以我已经实现sizeForItemAtIndexPath委托方法...的CollectionView不同的单元尺寸上reloadItemAtIndex呼叫建立问题
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath{
CGSize estimatedSize;
estimatedSize.width = collectionView.frame.size.width - 2* MARGIN_8;
CGSize questionSize=[self sizeOfText:myData[indexPath.row] constraintWidth:estimatedSize.width constraintsHeight:MAXFLOAT andFont:CELL_FONT];
estimatedSize.height = ceil(questionSize.height>MINIMUM_HEIGHT_OF_OPTION_TEXT?questionSize.height:MINIMUM_HEIGHT_OF_OPTION_TEXT);return estimatedSize;}
现在的问题是,当用于更新所选择的细胞,作为呼叫reloaItemAtItem方法....
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
userSelection = (int)indexPath.row;
[self.collectionView reloadItemsAtIndexPaths:@[indexPath]];}
它说
UICollectionView recieved layout attributes for a cell with an index path that does not exist: <NSIndexPath: 0x147a0190> {length = 2, path = 1 - 0}
并且屏幕停止响应。但是,当给所有的单元格相同的大小这个问题不来,它的工作正常。任何人都可以告诉问题是什么?
我们可以制作不同大小的单元格,而无需自定义流布局,因为我这样做并且它运行良好....但是发生reloadItemAtIndex方法调用的问题。我没有得到为什么这个运行正常reloadData但不reloadItemAtIndex调用。 – Dipika
嘿这个问题得到解决问题是在我的sizeOfText:(NSString *)constraintWidth:(float)constraintsHeight(float)andFont:(float)方法。反正thxs @harish – Dipika
好吧,这很好,很高兴听到这一点。 –