Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 如何在Swift中将刷卡操作发送到UIView_Ios_Swift_Uiswipegesturerecognizer_Swipeview_Koloda - Fatal编程技术网

Ios 如何在Swift中将刷卡操作发送到UIView

Ios 如何在Swift中将刷卡操作发送到UIView,ios,swift,uiswipegesturerecognizer,swipeview,koloda,Ios,Swift,Uiswipegesturerecognizer,Swipeview,Koloda,我正在尝试克隆Tinder,已经完成了Yalantis/Koloda()的左击(讨厌的人)和右击(喜欢的人)。我也有两个按钮喜欢/不喜欢的图像。我希望当我触摸喜欢/不喜欢的图像时,我的主视图将向左/向右滑动 let likeImageTap = UITapGestureRecognizer(target: self, action: #selector(HomeViewController.sendSwipeRightAction)) likeImage.isUserIntera

我正在尝试克隆Tinder,已经完成了Yalantis/Koloda()的左击(讨厌的人)和右击(喜欢的人)。我也有两个按钮喜欢/不喜欢的图像。我希望当我触摸喜欢/不喜欢的图像时,我的主视图将向左/向右滑动

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!
我尝试使用这个函数,然后在点击图像时调用它,这样我就可以做我想做的事情,就像滑动一样,但视图不会更改为下一个图像

public func swipe(_ direction: SwipeResultDirection, force: Bool = false)
 { 
//..
}
因此,我想向视图发送滑动操作,例如:

mainView.sendActions(for: .swipeLeft)
我该怎么办?谢谢你的建议。

中有代码

您的代码如下所示

@objc func sendSwipeRightAction() {
        mainView.swipe(.right)
    }

你创建了刷卡功能吗?没有,我想把动作刷卡发送到UIView,就像我用手刷卡一样。我应该如何创建滑动函数来实现这一点?根据我在lib中读到的内容,您只需要调用mainView.swipe(.left)OMG,我刚刚看到了它。谢谢你的回答。很好。谢谢,我刚刚克隆了一个示例并看到了它。
@objc func sendSwipeRightAction() {
        mainView.swipe(.right)
    }