concept Popover in category ios

appears as: Popover
iOS Development with Swift

This is an excerpt from Manning's book iOS Development with Swift.

Popover—Popovers appear as a bubble with an arrow pointing to an anchor view in your presenting view. Popovers only look like bubbles in regular-width size class environments—in compact-width, popover segues appear as full-screen modal segues.

  • Check the presentingViewController property and dismiss the view controller appropriately:
    func dismissMe() {
        if presentingViewController != nil {                             1
            // was presented via modal segue
           dismiss(animated: true, completion: nil)                      2
        } else {                                                         3
            // was pushed onto navigation stack
            navigationController!.popViewController(animated: true)      4
        }
    }
    • 1 If presented
    • 2 Dismisses view controller
    • 3 If pushed
    • 4 Pops view controller
    Similar to the way you can remove view controllers in code, they can also be displayed in code, rather than using storyboard segues. Table 9.1 shows the segues and their related methods.
    Table 9.1. Displaying and removing a view controller

    Managed by

    Equivalent segue

    Method to display

    Method to remove

    Navigation controller Show pushViewController popViewController
    View controller Modal/Popover present dismiss