I have an ImageView added to UIView. Tapping on the image take to Segmented Control which is also part of same UIView. I am trying to add swipe gestures to this segmented control.
Tried following.
override func viewDidLoad() {
super.viewDidLoad()
let rightSwipe = UISwipeGestureRecognizer(target: SegmentCotroller, action: Selector("swiped:"))
rightSwipe.direction = .Right
self.SegmentCotroller.addGestureRecognizer(rightSwipe)
}
func swiped(sender:UIGestureRecognizer){
print("Swiped.....!")
}
Code never reaches to swiped method when swiping right.
Any help is appreciated! Thanks
You need to se the swipe gestures target to self
let rightSwipe = UISwipeGestureRecognizer(target: self, action: Selector("swiped:"))
rightSwipe.direction = .Right
self.segmentController.addGestureRecognizer(rightSwipe)
The target sets where the action will be executed so you want it pointing at wherever you have the action implemented.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With