PGSSoft / ParallaxView

tvOS controls and extensions that add parallax effect to your application.
https://pgssoft.github.io/ParallaxView/
MIT License
481 stars 50 forks source link

Setting a glowContainerView removes UICollectionViewCell#contentView from hierarchy #21

Open mskrischke opened 3 years ago

mskrischke commented 3 years ago

Hello and first of all thanks for a great library!

With version > 3.0.0 or more specifically since commit acaa9b6dc4f5051ae333033e05a080f4866dba2d I see an issue with setting a custom glowContainerView on the ParallaxEffectOptions property of my UICollectionViewCell. No matter how I set the glowContainerView property it results in the cell's contentView being removed from its superview and the cell has no visible content in the UICollectionView.

My cell inherits from ParallaxCollectionViewCell and in awakeFromNib() or setupParallax() I would like to customize the ParallaxEffectOptions by using the options property and set a different glowContainerView. The glowContainerView property however is at this point already initialized with the cell's contentView (happens in ParallaxCollectionViewCell#commonInit). Setting a different glowContainerView subsequently leads to the contentView being removed from its superview by a property observer. As commonInit is called from the initializer I couldn't find a way to set my own glowContainerView before the contentView is set as default.

My first guess for a fix would be to remove the property observer on glowContainerView so that it doesn't change the view hierarchy. I am not sure of possible side effects however.

Kind regards and all the best, Markus

koczka commented 3 years ago

I have the exact same issue, the only difference is I don't use a nib for the ui, I built it from code.

romainbiard commented 3 years ago

Same issue here

cxfksword commented 2 years ago

Same issue in tvOS 15.0 SwiftUI