Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/105.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/19.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 枚举错误';“成员”;不是一种;“枚举”;_Ios_Swift - Fatal编程技术网

Ios 枚举错误';“成员”;不是一种;“枚举”;

Ios 枚举错误';“成员”;不是一种;“枚举”;,ios,swift,Ios,Swift,我正在使用KolodaView库: public enum SwipeResultDirection: String { case Left case Right ... } 在这个库中,在其delegate方法中有一个公开定义的函数: func koloda(koloda: KolodaView, didSwipeCardAtIndex index: UInt, inDirection direction: SwipeResultDirection) {} SwipeResul

我正在使用
KolodaView
库:

public enum SwipeResultDirection: String {
  case Left
  case Right
  ...
}
在这个库中,在其
delegate
方法中有一个公开定义的函数:

func koloda(koloda: KolodaView, didSwipeCardAtIndex index: UInt, inDirection direction: SwipeResultDirection) {}
SwipeResultDirection
是一个枚举,在库中定义:

public enum SwipeResultDirection: String {
  case Left
  case Right
  ...
}
但是当我在我的
ViewController
中访问它时,它的错误是

“Right”不是一种“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
  }
}

我不熟悉这个框架,但我认为应该是这样的:

extension ViewController: KolodaViewDelegate {
    func koloda(koloda: KolodaView, didSwipeCardAtIndex index: UInt, inDirection direction: SwipeResultDirection) {
        if direction == .Right {
            print("Apple")
        } else if direction == .Left {
            print("Cherry")
        }
    }
}

我不熟悉这个框架,但我认为应该是这样的:

extension ViewController: KolodaViewDelegate {
    func koloda(koloda: KolodaView, didSwipeCardAtIndex index: UInt, inDirection direction: SwipeResultDirection) {
        if direction == .Right {
            print("Apple")
        } else if direction == .Left {
            print("Cherry")
        }
    }
}

正如我所看到的,这里有函数声明,没有调用它。Put:
func koloda(koloda:KolodaView,didswipecardatinex index:UInt,间接方向:SwipeResultDirection){
哦,我认为它的使用方式与
tableViewDelegate
相同。既然我可以手动将
方向
作为参数传递,那么我该如何调用它呢?您不需要调用它。从github中,我看到它是在刷卡之前调用的。您需要实现它来告诉调用者是否可以刷卡。顺便问一下,您想要实现什么?我想要实现如果我向右滑动,则打印“Apple”,如果向左滑动,则打印“Cherry”。请您使用
示例
项目创建一个工作示例可以吗?请查看我的答案,并告诉我这是否是您想要的。正如我所看到的,这里有函数声明,而不是调用它。Put:
func koloda(科洛达:科洛达视图,didSwipeCardAtIndex:UInt,间接方向:SWIPERSULT方向){
哦,我认为它的使用方式与
tableViewDelegate
相同。既然我可以手动将
方向
作为参数传递,那么我该如何调用它呢?您不需要调用它。从github中,我看到它是在刷卡之前调用的。您需要实现它来告诉调用者是否可以刷卡。顺便问一下,您想要实现什么?我想要实现如果我向右滑动,打印“Apple”,如果向左滑动,打印“Cherry”。请您使用
示例
项目创建一个工作示例可以吗?查看我的答案,并告诉它是否是您想要的。虽然我无法打印任何内容,但它解决了错误,谢谢兄弟!尽管我无法打印任何内容,但它解决了错误,谢谢兄弟!