0

I am trying to clone Tinder, have done with swipe left (dislike person) and right (like person) by Yalantis/Koloda (https://github.com/Yalantis/Koloda). I also have two images for button like/dislike. I wish my mainView will swipe Left/Right when I touch like/dislike image.

let likeImageTap = UITapGestureRecognizer(target: self, action: #selector(HomeViewController.sendSwipeRightAction))
        likeImage.isUserInteractionEnabled = true
        likeImage.addGestureRecognizer(likeImageTap)

How should I put in this func?

    @objc func sendSwipeRightAction() {
        
    }

This is my protocols

extension HomeViewController: KolodaViewDataSource, KolodaViewDelegate {
   //...
       func koloda(_ koloda: KolodaView, didSwipeCardAt index: Int, in direction: SwipeResultDirection)
    {
        if direction == .left {
          //...
          print ("swipe left")
        }
        if direction == .right {
          //...
          print("swipe right")
        }
    }
}

This is my view

@IBOutlet var mainView: KolodaView!

I try to use this func, then call it when image tapped, so I can do what I want same as swipe, but the view not change to next image.

public func swipe(_ direction: SwipeResultDirection, force: Bool = false)
 { 
//..
}

So I want to send swipe action to the view, example:

mainView.sendActions(for: .swipeLeft)

How should I do? Thanks for your suggestion.

4
  • did you create swipe function?
    – aiwiguna
    Commented Jul 15, 2020 at 20:24
  • No, I want to send action swipe to UIView, like I swipe by my hand. How should I create swipe function to do that?
    – Tuan Ho Si
    Commented Jul 15, 2020 at 20:25
  • from what i read in the lib, you only need call mainView.swipe(.left)
    – aiwiguna
    Commented Jul 15, 2020 at 20:27
  • OMG, I have just see it. Thanks for your answer.
    – Tuan Ho Si
    Commented Jul 15, 2020 at 20:40

1 Answer 1

1

There is code in example

kolodaView.swipe(.left)
kolodaView.swipe(.right)

your code will be like this

@objc func sendSwipeRightAction() {
        mainView.swipe(.right)
    }
1
  • Nice. Thanks, I have just cloned Example and see it.
    – Tuan Ho Si
    Commented Jul 15, 2020 at 20:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.