我在func createDetailView()这个函数中有错误

时间:2015-03-16 10:11:42

标签: ios objective-c iphone swift

我在func createDetailView()函数中有错误

enter image description here

 

func handleProductGesture(recognizer : UISwipeGestureRecognizer) {

    if(UISwipeGestureRecognizerDirection.Left == recognizer.direction)
    {
     self.rightScrollBtnPressed(nil)
    }
    if(UISwipeGestureRecognizerDirection.Right == recognizer.direction)
    {
      self.leftScrollBtnPressed(nil)
    }


}

func createDetailView() { scrollView.contentSize = CGSizeMake(CGFloat(320*(pageImages.count)), scrollView.frame.height) scrollView.showsHorizontalScrollIndicator = false scrollView.scrollEnabled = false scrollView.bounces = false

    let rightSwipe = UITapGestureRecognizer(target: self, action: Selector(handleProductGesture()))
    rightSwipe.direction = UISwipeGestureRecognizerDirection.Right
    rightSwipe.delegate = self

    view.addGestureRecognizer(rightSwipe)

    let leftSwipe = UITapGestureRecognizer(target: self, action: Selector(handleProductGesture()))
    leftSwipe.direction = UISwipeGestureRecognizerDirection.Left
    leftSwipe.delegate = self
    view.addGestureRecognizer(leftSwipe)

     next = indexNumber-1
    self.rightScrollBtnPressed(nil)

}

1 个答案:

答案 0 :(得分:1)

问题在于您的选择器传递代码。您需要在您尝试调用它的代码中将方法名称指定为字符串。

将这些更改为:

let rightSwipe = UITapGestureRecognizer(target: self, action: Selector("handleProductGesture:"))

let leftSwipe  = UITapGestureRecognizer(target: self, action: Selector("handleProductGesture:"))