Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swift :Segmented control with a swipe gesture between views

I'm using a UIContainer to switch between views using segmented control + swipe gesture.

My storyboard is like this one.enter image description here

Override func viewDidLoad() {
super.viewDidLoad()

var swipeRight = UISwipeGestureRecognizer(target: self, action: "respondToSwipeGesture:")
swipeRight.direction = UISwipeGestureRecognizerDirection.Right
self.view.addGestureRecognizer(swipeRight)

}

I tired many open resources for Github but it is written in objective-C? Can anyone help

like image 876
user3662992 Avatar asked Oct 19 '22 07:10

user3662992


1 Answers

func respondToSwipeGesture(gestureReconizer: UISwipeGestureRecognizer) {
    self.performSegueWithIdentifier("SegueFromFirstScreenToSecond", sender: nil)     
}

Here is the method you would have to implement if you already have created the segue and named it "SegueFromFirstScreenToSecond". If you have not already made the segue, do not worry! It is as easy as drawing from the first responder of the view in storyboard to the next screen and then setting the identifier to "SegueFromFirstScreenToSecond".

Best of luck!

like image 200
alex1511 Avatar answered Oct 21 '22 22:10

alex1511