我已經編寫了代碼以在圖庫應用程序中滑動圖像。當它彈出到一個大的圖像時,我想左右滑動圖像並寫下以下代碼。但它仍然無法工作。是否有人建議代碼有什麼問題?如何在彈出圖像時左右滑動圖像
override func viewDidLoad() {
super.viewDidLoad()
self.imageview.image = self.Image
var leftSwipe = UISwipeGestureRecognizer(target:self, action: Selector("handleSwipes:"))
var rightSwipe = UISwipeGestureRecognizer(target:self, action: Selector("handleSwipes:"))
leftSwipe.direction = .Left
rightSwipe.direction = .Right
view.addGestureRecognizer(leftSwipe)
view.addGestureRecognizer(rightSwipe)
}
func handleSwipes(sender: UISwipeGestureRecognizer) {
if (sender.direction == .Left){
self.imageview.image = self.Image
}
if (sender.direction == .Right){
self.imageview.image = self.Image
}
}
應該是什麼一旦它在viewDidLoad中被調用,函數SwipeGestureRecognizer的返回類型是什麼? – Venky
編輯我的答案 – datha