Instance Method

show(_:sender:)

Presents the specified view controller as the primary view controller in the split view interface.

Declaration

func show(_ vc: UIViewController, sender: Any?)

Parameters

vc

The view controller to display in the primary (or master) location of the split view interface.

sender

The object that made the request to show the view controller.

Discussion

Whenever possible, use this method (instead of modifying the contents of the viewControllersproperty directly) to replace the primary view controller of your split view interface. This method displays the specified view controller in the best way possible given the current size class in effect.

Typically, you call this method from an action method when you want to replace the primary view controller with the one specified in vc. This method calls the split view controller delegate’s splitViewController(_:show:sender:) method to give the delegate an opportunity to show the view controller. If the delegate does not show the view controller, the split view controller shows it using the following heuristics:

  • In a horizontally regular environment, the split view controller installs vc as the primary view controller unless vc is already a child of the primary view controller, in which case it installs vc as the secondary view controller.

  • In a horizontally compact environment, the split view controller presents vc modally.

See Also

Action Methods for Displaying View Controllers

func showDetailViewController(UIViewController, sender: Any?)

Presents the specified view controller as the secondary view controller of the split view interface.