VerticalCardSwiper icon indicating copy to clipboard operation
VerticalCardSwiper copied to clipboard

Refresh Card View on view resize

Open mohit196 opened this issue 6 years ago • 7 comments

New Issue Checklist

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

mohit196 avatar Mar 29 '19 07:03 mohit196

  • 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.

JoniVR avatar Mar 30 '19 13:03 JoniVR

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.

VerticalCardSwiper-master-2.zip

mohit196 avatar Apr 02 '19 08:04 mohit196

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)

JoniVR avatar Apr 02 '19 14:04 JoniVR

Thanks for update Joni

Use Case:

  • Swipe 2-3 cards upward.
  • Now Swipe away the topmost card, you will see the issue.

Simulator Screen Shot - iPhone XR - 2019-04-03 at 11 24 32

mohit196 avatar Apr 03 '19 05:04 mohit196

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.

JoniVR avatar Apr 03 '19 11:04 JoniVR

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()
}

VerticalCardSwiper-master-2.zip

JoniVR avatar Apr 11 '19 12:04 JoniVR

Yes, and the issue still exists.

I tried: cardSwiper.layoutIfNeeded() and cardSwiper.verticalCardSwiperView.layoutIfNeeded()

mohit196 avatar Apr 15 '19 08:04 mohit196