UIMenuItem Class Reference

Inherits from
Conforms to
Framework
/System/Library/Frameworks/UIKit.framework
Availability
Available in iOS 3.2 and later.
Declared in
UIMenuController.h
Related sample code

Overview

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.

Tasks

Creating a Menu Item

Accessing Menu-Item Attributes

Properties

action

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

@property SEL action
Discussion

The action selector cannot be NULL.

Availability
  • Available in iOS 3.2 and later.
Declared In
UIMenuController.h

title

The title of the menu item.

@property(copy) NSString *title
Discussion

The title cannot be nil.

Availability
  • Available in iOS 3.2 and later.
Declared In
UIMenuController.h

Instance Methods

initWithTitle:action:

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

- (id)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.

Availability
  • Available in iOS 3.2 and later.
Declared In
UIMenuController.h