Wednesday, October 19, 2016

3 ways to perform navigation in swift

1) Use Seque. You can't add Seque programmatically. You can only add a seque in storyboard. Press ctrl and mouse hold your current viewController (the square icon in the View Controller Scene), stretch it to the view controller you want to navigate to, and drop it. Click the show button from the menu. Set an ID for the Seque. when performing navigation, call self.performSegueWithIdentifier("ViewSeque", sender: self), it will trigger the following method in your view controller override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?){} you can customize the navigation for the next view. This is on base of stack

2) Use self.navigationController?.pushViewController(tableViewControllerObj, animated: true) to perform navigation. You need to embed your viewcontroller in a navigation controller. 



3) Use self.presentViewController(tableViewControllerObj, animated: true, completion: get) to present whatever view you like.

pushViewController manage your view stack, presentViewController is to display whatever view you want to display