Class

UIMenuSystem

An object representing a main or contextual menu system.

Declaration

class UIMenuSystem : NSObject

Overview

A menu system groups root menus together. The main system has only one root menu while the context system can have multiple root menus, each built in different UIResponder objects like a view controller.

Use UIMenuSystem in your implementation of buildMenu(with:) to isolate changes to a specific system.

override func buildMenu(with builder: UIMenuBuilder) {
    super.buildMenu(with: builder)
    
    // Ensure that the builder is modifying the menu bar system.
    guard builder.system == UIMenuSystem.main else { return }

    // ...
}

You can also use a menu system to rebuild or revalidate menus as changes occur in your app. To rebuild a menu, call the setNeedsRebuild() method. Call setNeedsRevalidate() when you need the menu system to revalidate a menu.

To see an example of using a menu systen, see Adding Menus and Shortcuts to the Menu Bar and User Interface.

Topics

Getting a Menu System

class var main: UIMenuSystem

The main menu system.

class var context: UIMenuSystem

The context menu system.

Rebuilding a Menu System

func setNeedsRebuild()

Tells the menu system to rebuild all of its menus.

Revalidating a Menu System

func setNeedsRevalidate()

Tells the menu system to validate all of its menus.

Relationships

Inherits From

Conforms To

See Also

App Menus

class UIMenu

A container for grouping related menu elements in an app menu or contextual menu.

protocol UIMenuBuilder

An interface for adding and removing menus from a menu system.