Yalantis / Koloda

KolodaView is a class designed to simplify the implementation of Tinder like cards on iOS.
https://yalantis.com
MIT License
5.37k stars 805 forks source link

kolodaNumberOfCards is not being called when push new view controller #461

Open atalayasa opened 3 years ago

atalayasa commented 3 years ago

Hello, thank you very much for that great library. In my view controller I have KolodaView and buttons for programmatically dragging cards. When user swipe right it needs to go to the new view controller. So, I implemented following methods for this feature.

    func koloda(_ koloda: KolodaView, draggedCardWithPercentage finishPercentage: CGFloat, in direction: SwipeResultDirection) {
        switch direction {
        case .right:
            if finishPercentage > 90 {
                userDidRightSwipe()
            }
        default:
            return
        }
    }

    @IBAction func nextBtnPressed() {
        userDidRightSwipe()
    }

    private func userDidRightSwipe() {
        kolodaView.swipe(.right)
        navigationController?.pushViewController(ChatVC(), animated: true)
    }

When I click next button kolodaNumberOfCards method is firing and cards are decreasing as it's supposed to be. However when I called same method in draggedCardWithPercentage kolodaNumberOfCards method is not being called and cards are never finishing. My question if I'd like to push a new view controller in which delegate method should I apply?

Edit 1: I think the problem is about pushing new view controller because when I swipe left kolodaNumberOfCards is being called but if I try to swipe right (which is pushing new vc) kolodaNumberOfCards is not being called. Edit 2: I have also implemented didSwipeCardAt and push new view controller inside it but this time when I call navigationController?.pushViewController(ChatVC(), animated: true) inside it animation is not working.