Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class ViewController: UIViewController {
- @IBOutlet weak var labelToSwipe: UILabel!
- // I want to define a swipe. I want that swipe to be directionally left.
- // I want to define an action that is taken upon the swipe.
- // I want that action to consist of a method, that takes me to secondVC.
- override func viewDidLoad() { //why does this not work outside of the viewDidLoad method?
- super.viewDidLoad()
- initializeSwipeLeftOnLabel()
- }
- func initializeSwipeLeftOnLabel() {
- let swipeLeft = UISwipeGestureRecognizer(target: self, action: "goToSecondVC:")
- swipeLeft.direction = UISwipeGestureRecognizerDirection.Left
- self.labelToSwipe.addGestureRecognizer(swipeLeft)
- }
- func goToSecondVC(sender: UISwipeGestureRecognizer) {
- println("about to init secondVC")
- var varToDesignateSecondVC = self.storyboard?.instantiateViewControllerWithIdentifier("secondVC") as SecondViewController
- println("about to present secondVC")
- self.presentViewController(varToDesignateSecondVC, animated: true, completion: nil)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement