Advertisement
Guest User

Untitled

a guest
Jan 29th, 2015
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. class ViewController: UIViewController {
  2. @IBOutlet weak var labelToSwipe: UILabel!
  3.  
  4. // I want to define a swipe. I want that swipe to be directionally left.
  5. // I want to define an action that is taken upon the swipe.
  6. // I want that action to consist of a method, that takes me to secondVC.
  7.  
  8. override func viewDidLoad() { //why does this not work outside of the viewDidLoad method?
  9. super.viewDidLoad()
  10. initializeSwipeLeftOnLabel()
  11. }
  12.  
  13. func initializeSwipeLeftOnLabel() {
  14. let swipeLeft = UISwipeGestureRecognizer(target: self, action: "goToSecondVC:")
  15. swipeLeft.direction = UISwipeGestureRecognizerDirection.Left
  16. self.labelToSwipe.addGestureRecognizer(swipeLeft)
  17. }
  18.  
  19. func goToSecondVC(sender: UISwipeGestureRecognizer) {
  20. println("about to init secondVC")
  21. var varToDesignateSecondVC = self.storyboard?.instantiateViewControllerWithIdentifier("secondVC") as SecondViewController
  22.  
  23. println("about to present secondVC")
  24. self.presentViewController(varToDesignateSecondVC, animated: true, completion: nil)
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement