我在func createDetailView()函数中有错误
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) }
答案 0 :(得分:1)
问题在于您的选择器传递代码。您需要在您尝试调用它的代码中将方法名称指定为字符串。
将这些更改为:
let rightSwipe = UITapGestureRecognizer(target: self, action: Selector("handleProductGesture:"))
let leftSwipe = UITapGestureRecognizer(target: self, action: Selector("handleProductGesture:"))