Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Inserting Subview Below UICollectionView

When I add a subview below a UICollectionView, sometimes the subview shows up above the UICollectionView cells. Here is the subview insertion code:

[self.collectionView insertSubview:self.garmentView atIndex:0];

Not sure if I'm not following a best practice or otherwise missing something obvious. Any assistance appreciated.

** Edit ** It might be worth noting that this only happens in landscape, when the rightmost cell is zoomed in.

like image 287
Michael Mangold Avatar asked Oct 29 '25 15:10

Michael Mangold


1 Answers

I think

self.garmentView.layer.zPosition = -1
[self.collectionView insertSubview:self.garmentView atIndex:0];

will solve your problem. My guess is that it can happen that the collection view cells gets added with a lower index than your garmentView. See this question for a more thorough discussion about subview positions.

like image 118
Lev Landau Avatar answered Oct 31 '25 06:10

Lev Landau