Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Taylor Smith
iOS Development Techdegree Graduate 14,153 Pointsusing 2 gesture recognizers in storyboard mode in Xcode 6.1 (swift)
hello! I've been experimenting with using custom animations for segues between view controllers. Adding a the swipe gesture recognizer straight to the storyboard works great as a segue. However, Xcode tells me in order to add a left AND right gesture, I need to drag in 2 gesture recognizers. However, the segue only goes under 1 of them.
So I guess my question is, How can I use 2 gesture recognizers (in storyboard mode) on ONE view controller???
2 Answers
Michael Hulet
47,913 PointsIn Xcode 6.1 on my Mac, it lets me add 2 UISwipeGestureRecognizers just fine. If you're asking how to perform the same segue with both UISwipeGestureRecognizers, what I'd do is make sure you set the Identifier for the segue you want to execute, then make an @IBAction for the UISwipeGestureRecognizer that doesn't have the segue connected to it. If that @IBAction's function, just call the performSegueWithIdentifier function, like this:
performSegueWithIdentifier("YourSegueIdentifierHere", sender: nil)
You could also set the sender: to an @IBOutlet of the UISwipeGestureRecognizer that fired the @IBAction, but then you have to go through the trouble of setting up that @IBOutlet, so I just think it's easier to set it to nil
Taylor Smith
iOS Development Techdegree Graduate 14,153 PointsI can add 2 just fine.... but only 1 direction works at a time. For example, I have 1 GR set to swipe left that will segue to the next view controller. But when I add another GR to swipe right to either exit that view or segue to a different view controller, nothing happens.
i havne't done any coding by the way, this is all done on the main storyboard.