Refresh Card View on view resize
mohit196 opened this issue · 7 comments
New Issue Checklist
- I updated VerticalCardSwiper to the latest version.
- I read the Contribution Guidelines.
- I read the documentation.
- I searched for existing GitHub issues.
Issue Description
Right now If I am resizing the cardView the card cells are not adjusting to the new frame.
Steps:
- Create a cardView Height constraint
- Assign a new value to height constraint. -- (Cell will not update its frame)
on reloading the CardView it is still giving me some random behavior because of the previous collection view height.
Environment
- iOS Version: 12.0
- Device(s): iPhone XR Simulator
- Xcode Version: 10.2
- Create a cardView Height constraint
Do you mean creating height constraints for objects inside the cardView?
I would need some clarification on where exactly you are adding a constraint.
A demo project would be even better.
Are you using the sizeForItem
delegate function?
Because that function is meant to allow you to change card sizes.
I added an NSLayoutConstraint on cardSwiper view height and in didSwipeCardAway, I am updating the height constraint. After updating the cell should opt to new constraints.
I have made some changes to the existing project.
So are you saying that the cards don't adapt their size right away once you swipe one away for the first time?
So does adding the following line:
cardSwiper.verticalCardSwiperView.layoutIfNeeded()
below the line where you update the constraint (kind of) fix it for you? (just so I understand what you're talking about)
Yes, I see it now, alright I'll look into what's causing this sometime when I get the time for it.
If you find a solution yourself in the meantime, feel free to post it here or submit a Pull Request.
Hi @mohit196
Quick question, did you try my previous solution?
If I call cardSwiper.layoutIfNeeded()
after changing the constraint value it looks like it works to me?
func didSwipeCardAway(card: CardCell, index: Int, swipeDirection: SwipeDirection) {
cardViewHeightConstraint.constant = 600.0
cardViewHeightConstraint.priority = .required
cardSwiper.layoutIfNeeded()
}
Yes, and the issue still exists.
I tried:
cardSwiper.layoutIfNeeded()
and
cardSwiper.verticalCardSwiperView.layoutIfNeeded()