Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // ViewController.swift
- // OutletRetention
- //
- // Created by Thomas Krajacic on 8.3.2015.
- // Copyright (c) 2015 Thomas Krajacic. All rights reserved.
- //
- import Cocoa
- class ViewController: NSViewController {
- override func viewDidLoad() {
- super.viewDidLoad()
- // Do any additional setup after loading the view.
- }
- override var representedObject: AnyObject? {
- didSet {
- // Update the view, if already loaded.
- }
- }
- @IBAction func present(sender: NSButton) {
- let storyboard = NSStoryboard(name: "Main", bundle: nil)
- switch sender.title {
- case "A":
- let vc = storyboard?.instantiateControllerWithIdentifier("A") as! NSViewController
- self.showViewController(vc)
- case "B":
- let vc = storyboard?.instantiateControllerWithIdentifier("B") as! NSViewController
- self.showViewController(vc)
- default: break
- }
- }
- let animator = FadeTransitionAnimator()
- let swipe = FadeTransitionAnimator()
- func showViewController(viewController: NSViewController) {
- // hide all others
- self.dismissAllViewControllers()
- self.addChildViewController(viewController)
- // present new viewcontroller
- presentViewController(viewController, animator: swipe)
- }
- func dismissAllViewControllers() {
- if let previousVC = self.childViewControllers.last as? NSViewController {
- self.dismissViewController(previousVC)
- previousVC.removeFromParentViewController()
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement