我正在使用KolodaView
库:https://github.com/Yalantis/Koloda
在这个库中,delegate
方法中有一个公开定义的函数:
func koloda(koloda: KolodaView, didSwipeCardAtIndex index: UInt, inDirection direction: SwipeResultDirection) {}
SwipeResultDirection
是枚举,在库中定义:
public enum SwipeResultDirection: String {
case Left
case Right
...
}
但是当我在ViewController
中访问它时,它的错误是
'Right" is not a type of "SwipeResultDirection"
这是我的代码:
class ViewController: UIViewController {
@IBOutlet weak var kolodaView: KolodaView!
}
extension ViewController: KolodaViewDelegate {
func koloda(koloda: KolodaView, didSwipeCardAtIndex index: UInt, inDirection direction: SwipeResultDirection.Right) {
// Error here
return
}
}
答案 0 :(得分:0)
我不熟悉这个框架,但我认为它应该是这个:
extension ViewController: KolodaViewDelegate {
func koloda(koloda: KolodaView, didSwipeCardAtIndex index: UInt, inDirection direction: SwipeResultDirection) {
if direction == .Right {
print("Apple")
} else if direction == .Left {
print("Cherry")
}
}
}