過程中添加我添加了一個以collectionView cell
的選擇和重新加載項目,但認爲不在第一選擇可見,其只有再次單擊單元格。後可見第一次加載collectionView時,首先選擇collectionView單元格,添加的視圖被添加但不可見,大小增加,只有第二次選擇後視圖纔可見。有何看法加入到uicollectionview細胞沒有出現該選擇
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
selectedIndexPath = indexPath;
PastPicksGameCollectionViewCell *cell = (PastPicksGameCollectionViewCell *)[collectionView cellForItemAtIndexPath:indexPath];
UIView *view = [[UIView alloc]initWithFrame:CGRectMake(50,122, 150, 120)];
[view setBackgroundColor:[UIColor blueColor]];
[cell.contentView addSubview:view]
[pastPicksGameCollectionView reloadItemsAtIndexPaths:@[selectedIndexPath]];
}
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
if ([indexPath isEqual:selectedIndexPath]) {
return CGSizeMake(320, 200);
}
return CGSizeMake(300, 120);
}