How to rewrite controller view on panGesture

I am trying to go to the view controller. segue identifier is β€œOrange” (another view controller is an orange view only). The view controller is taken out of the storyboard and connected to the image view in my main controller. I want to call this using gesture recognizer. Therefore, when a panorama is detected, it simply goes to the view controller.

This is my attempt:

@IBOutlet var panGesture: UIPanGestureRecognizer! @IBAction func onPan(sender: UIPanGestureRecognizer) { if panGesture.state == .Ended { print("panned") performSegueWithIdentifier("Orange", sender: sender) } } 

However, this does not work. I know that it detects panning, but it does not complete the session.

I read how to introduce segue from iOS. How to do a software launch using fast .

+6
source share
3 answers

Try presenting ViewController with an instance: -

  • Make sure your first VC controller has a navigation controller integrated

  • Providing your ViewController : StoryBoardID: - Select the ViewController in your storyboard that you want to present β†’ Identity Inspector β†’ StoryBoard ID. Give your VC the storyboard identifier: "vc2SceneVC_ID"

  • Create and press VC as follows: -

     @IBAction func onPan(sender: UIPanGestureRecognizer) { if panGesture.state == .Ended { print("panned") let vc2Scene = self.storyboard?.instantiateViewControllerWithIdentifier("vc2SceneVC_ID") as! VC2 self.navigationController?.pushViewController(vc2Scene, animated: true) } 

Apple Documentation for Navigation Controller : - UINavigationController Apple Doc

PS: - Prefers to create an instance of navigation through ViewControllers using the instance rather performSegueWithIdentifier("Orange", sender: sender) Because this way you get the ability to transfer data back to these viewControllers, and also prevents memory leaks in most cases.

+4
source

Step 1: Control + Click from the first ViewController (where the view controller lab is shown) and drag to the second ViewController

Step 2: select the type of segue

Step 3: select the shogi and set the identifier

and where you need to make a call only to call self.performSegueWithIdentifier("test", sender: nil)

sorry for bad english

+2
source

Orange should be the identifier of your segue in the storyboard, not the identifier of the view controller.

If your segue ID is set correctly, try checking if your gesture callback is in the main thread.

Let me know in the comments that you have a problem.

+1
source

All Articles