我正在尝试克隆Tinder,已经用Yalantis/Koloda (https://github.com/Yalantis/Koloda)完成了向左(不喜欢的人)和向右(喜欢的人)滑动。我也有两个按钮喜欢/不喜欢的图片。我希望当我触摸喜欢/不喜欢的图片时,我的mainView可以向左/向右滑动。
let likeImageTap = UITapGestureRecognizer(target: self, action: #selector(HomeViewController.sendSwipeRightAction))
likeImage.isUserInteractionEnabled = true
likeImage.addGestureRecognizer(likeImageTap)我该如何放入这个函数呢?
@objc func sendSwipeRightAction() {
}这是我的协议
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")
}
}
}这是我的观点
@IBOutlet var mainView: KolodaView!我试着使用这个函数,然后在图像点击时调用它,这样我就可以像swipe一样做我想做的事情,但视图不会切换到下一个图像。
public func swipe(_ direction: SwipeResultDirection, force: Bool = false)
{
//..
}因此,我想向视图发送卷帘操作,例如:
mainView.sendActions(for: .swipeLeft)我该怎么办?谢谢你的建议。
发布于 2020-07-16 04:29:36
在example中有代码
kolodaView.swipe(.left)
kolodaView.swipe(.right)您的代码将如下所示
@objc func sendSwipeRightAction() {
mainView.swipe(.right)
}https://stackoverflow.com/questions/62923026
复制相似问题