我使用KolodaView库创建类似Tinder的滑动视图:https://github.com/Yalantis/Koloda
我在我的delegate
中实施了ViewController
方法,如下所示:
class ViewController: UIViewController {
@IBOutlet weak var kolodaView: KolodaView!
override func viewDidLoad() {
super.viewDidLoad()
kolodaView.dataSource = self
kolodaView.delegate = self
}
extension ViewController: KolodaViewDelegate {
func koloda(koloda: KolodaView, didSwipeCardAtIndex index: UInt, inDirection direction: SwipeResultDirection) {
if direction == .Right {
print("apple")
} else if direction == .Left {
print("cherry")
}
}
}
当我刷卡时,它应该打印apple
或cherry
,但是当我运行它时它什么都不做。