6

I am building an app for the first time using Storyboards. I have a scene which I would like to have open another scene when there is a long tap on a particular button. I am able to add the UILongPressGestureRecognizer with no problem, but I can't figure out how to have that gesture be the segue to the other scene. Doesn't seem to matter what I Ctrl-Drag, nothing works.

Am I missing something obvious?

Thanks, Ken

djromero
  • 19,551
  • 4
  • 71
  • 68
macgeezer
  • 484
  • 1
  • 6
  • 15

2 Answers2

12

You can control-drag from your first controller's window to your second controller to create the segue, and then you can call performSegueWithIdentifier in your GestureRecognizer method.

danqing
  • 3,348
  • 2
  • 27
  • 43
  • the problem here it loads the view again it doesnt retain the values inside. – baste Jul 09 '13 at 08:35
  • This [answer](http://stackoverflow.com/a/18113316/1966109) to a similar question may also be useful as it gives more details to implement what you need. – Imanou Petit Jan 10 '15 at 02:42
  • thanks. worked for me as well. [Here](http://stackoverflow.com/questions/9176215/understanding-performseguewithidentifier) is a nice explanation of performSegueWithIdentifier. – asdr Jul 12 '16 at 12:50
4

It's now possible to do it all in your Storyboard visually. Every gesture recognizer has Triggered Segues in Connections Inspector.

Rudolf Adamkovič
  • 31,030
  • 13
  • 103
  • 118
  • 2
    Actually It seems that you cant connect segue to long press in storyboard. Which personally I hate. I use it a lot to simulate highlight on big touchable objects and need add segue identifiers and performSegue... – yershuachu Sep 17 '14 at 11:41