Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refresh Card View on view resize #39

Open
4 tasks done
mohit196 opened this issue Mar 29, 2019 · 7 comments
Open
4 tasks done

Refresh Card View on view resize #39

mohit196 opened this issue Mar 29, 2019 · 7 comments
Labels

Comments

@mohit196
Copy link

mohit196 commented Mar 29, 2019

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
@JoniVR
Copy link
Owner

JoniVR commented Mar 30, 2019

  • 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 JoniVR added the needs more detail Provide more detail to the issue label Mar 30, 2019
@mohit196
Copy link
Author

mohit196 commented Apr 2, 2019

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

@JoniVR
Copy link
Owner

JoniVR commented Apr 2, 2019

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)

@mohit196
Copy link
Author

mohit196 commented Apr 3, 2019

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

@JoniVR
Copy link
Owner

JoniVR commented Apr 3, 2019

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 JoniVR added bug and removed needs more detail Provide more detail to the issue labels Apr 3, 2019
@JoniVR
Copy link
Owner

JoniVR commented Apr 11, 2019

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

@mohit196
Copy link
Author

Yes, and the issue still exists.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants