I am working with UICollectionView
. Never worked with
this before. So,I am facing lots of issues. One is am trying to add
UIView
as subview on UICollectionView
,for the purpose of showing
UIView
as Pop-Up view on tap of UICollectionViewCell
. I am able to add
subview to collectionView
. But problem is that when I scroll
UICollectionView
, the subview also scrolls with it. It want UIView
to
stick at bottom of UICollectionView
.It should not scroll with
UICollectionView
. It should be always visible on bottom of view. I
tried to add UIView
as footer but didn't worked.
Here is my code for footerView
- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"add footer view ");
UICollectionReusableView *reusableview = nil;
if (kind == UICollectionElementKindSectionFooter) {
UICollectionReusableView *footerview = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionFooter withReuseIdentifier:UICollectionElementKindSectionFooter forIndexPath:indexPath];
[footerview addSubview:popupView];
reusableview = footerview;
}
return reusableview;
}
-(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout referenceSizeForFooterInSection:(NSInteger)section
{
return CGSizeMake(dotsCollectionView.frame.size.width, 120);
}
Please suggest me if there's any other way to do this. Any help would be appreciated. Thanks
The UIView should not be a subview of the UICollectionView. It should be the siblings to the UICollectionView which will take bottom half of the parent view. In the case you want the UIView to be visible only when user selected a cell, you can play around with the height constraint (provided you added it) of the UIView. Set the height constraint constant to the value you want when user selected a cell and set it to 0 when you want it to be hidden.