-
Notifications
You must be signed in to change notification settings - Fork 3
iOS UIViewController Transitions
Kevin Leong edited this page Oct 31, 2016
·
1 revision
class ViewController: UIViewController {
@IBAction func didTapButton(_ sender: UIButton) {
// Instantiate the next view controller to display.
// This instantiates a view controller constructed in Interface Builder.
anotherViewController =
UIStoryboard(
name: "Main",
bundle: nil
).instantiateViewController(
withIdentifier: "com.example.SomeStoryboardIdentifier"
)
// Push the next view controller on the navigation controller stack and display
navigationController?.pushViewController(anotherViewContrroller, animated: true)
}
}
Name | Description |
---|---|
show | Adds the destination view controller onto the navigation controller's stack. The destination view controller's view is made visible, and a back button is added, which allows navigation back to the previous (source) view controller. |
show detail | |
present modally | |
popover presentation | |
custom |
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
// All segues for this UIViewController are handled by this method,
// so specific behavior must target via the segue's identifier, which is
// defined in the storyboard or programatically.
if segue.identifier == "showItemDetailSegueIdentifier" {
if let itemDetailViewController = segue.destinationViewController as? ItemDetailViewController {
// Table views return the selected index path, which can be
// used to pass the correct item to the detail view controller.
if selectedIndexPath = itemsTableView.indexPathForSelectedRow {
itemDetailViewController.item = items[selectedIndexPath.row]
}
}
}
}