简体   繁体   中英

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. 在此输入图像描述

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

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!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM