Swipe between dispatchers
I am trying to create doilies in the background. I have three different background colors. I made a button and when I click the button my background changes to the next scene. I want to change this and I want to swipe left or right to change the background and not click on the button. How can I achieve this.
here are some more details
my view controller
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
source to share
Swift version:
Add gesture recognizer:
override func viewDidLoad() {
super.viewDidLoad()
let recognizer: UISwipeGestureRecognizer = UISwipeGestureRecognizer(target: self, action: "swipeLeft:")
recognizer.direction = .Left
self.view .addGestureRecognizer(recognizer)
}
action function:
func swipeLeft(recognizer : UISwipeGestureRecognizer) {
self.performSegueWithIdentifier("MySegue", sender: self)
}
source to share
Ok I figured it out. The gesture was scrolled in the right pane of Xcode and it was the same as the button in the view. The only difference is that it is displayed on top and not inside the view. So after I realized it was as easy as holding down the ctrl button and dragging it into another view and it worked. Below are some images for some people if they stumble upon this:
source to share