Skip to content

Instantly share code, notes, and snippets.

View asvdw's full-sized avatar

Denis Willems asvdw

View GitHub Profile
@asvdw
asvdw / Swift-ViewController-Navigation.swift
Last active April 14, 2016 07:11
Navigation "in code"
// in appDelegate:
let controllerId = "target VC Storyboard ID"
let storyboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let initViewController: UIViewController = storyboard.instantiateViewControllerWithIdentifier(controllerId)
self.window?.rootViewController = initViewController
// *replace* current ViewController by anotherone:
let storyboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let targetViewController: UIViewController = storyboard.instantiateViewControllerWithIdentifier("target VC StoriboardID") as UIViewController
let navigationController: UINavigationController = self.navigationController!;
@asvdw
asvdw / gist:1ddc36410e3282780c6f72686fa19bb1
Created April 12, 2016 13:24 — forked from igordeoliveirasa/gist:d97272965b2cdd4d73c6
iOS - Swift - Show View Controller
let _storyboard = UIStoryboard(name: "Main", bundle: nil)
let vc = _storyboard.instantiateViewControllerWithIdentifier("countryTableViewController") as CountryTableViewController
vc.setupDelegate = self
self.showViewController(vc, sender: nil)
@asvdw
asvdw / ViewController-DismissKeyboard.swift
Last active November 17, 2017 09:04
iOS: Dismiss keyboard on click on view
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
let tap: UITapGestureRecognizer = UITapGestureRecognizer(target: self, action:
#selector(ViewController.dismissKeyboard))