iOS Developer Library

Developer

UIKit Framework Reference UIMenuItem Class Reference

Options
Deployment Target:

On This Page
Language:

UIMenuItem

Inheritance


Conforms To


Import Statement


Swift

import UIKit

Objective-C

@import UIKit;

Availability


Available in iOS 3.2 and later.

An instance of the UIMenuItem class represents a custom item in the editing menu managed by the UIMenuController object.

Custom menu items appear in the menu after any validated system items. A UIMenuItem object has two properties: a title and an action selector identifying the method to invoke in the handling responder object. Targets are not specified; a suitable target is found via normal traversal of the responder chain. To have custom menu items appear in the editing menu, you must add them to the menuItems property of the UIMenuController object.

  • Creates and returns a menu-item object initialized with the given title and action.

    Declaration

    Swift

    init(title title: String, action action: Selector)

    Objective-C

    - (instancetype)initWithTitle:(NSString *)title action:(SEL)action

    Parameters

    title

    The title of the menu item.

    action

    A selector identifying the method of the responder object to invoke for handling the command represented by the menu item.

    Return Value

    An initialized UIMenuItem object, or nil if there was a problem creating the object.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 3.2 and later.

  • title title Property

    The title of the menu item.

    Declaration

    Swift

    var title: String!

    Objective-C

    @property(nonatomic, copy) NSString *title

    Discussion

    The title cannot be nil.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 3.2 and later.

  • action action Property

    A selector identifying the method of the responder object to invoke for handling of the menu command.

    Declaration

    Swift

    var action: Selector

    Objective-C

    @property(nonatomic) SEL action

    Discussion

    The action selector cannot be NULL.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 3.2 and later.