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.
There is code in example
kolodaView.swipe(.left)
kolodaView.swipe(.right)
your code will be like this
@objc func sendSwipeRightAction() {
mainView.swipe(.right)
}