Website Links

Thursday 10 December 2015

Swift - Switching Views Programmatically

Sometimes you may want to do custom navigation, in this case you will want to know how to switch views programmatically. To do this you need to follow the following steps:
  1. Setup the view controller code, and set it as the view controller class against a view controller in your storyboard



  2. Set the storyboard id, this is how you will load the view from your storyboard



  3. Use the following code to change views (code styling is due to lack of space):
    
      ...
    
      let vc = self.storyboard!
        .instantiateViewControllerWithIdentifier
        ("SpellingListsViewController") 
        as! SpellingListsViewController
    
      self.presentViewController(vc, animated: true, 
        completion: nil)
    
      ...
    
    

No comments:

Post a Comment