From iPhone Development Wiki
Revision as of 10:15, 27 March 2014 by SharedRoutine (talk | contribs)
Jump to: navigation, search
Cydia Package
Developer Ryan Petrich
Package ID actionmenu
Latest Version 1.2.14

ActionMenu is an extension that adds extra options to the menu that pops up when you select text or tap-and-hold an item (such as an image or a table cell).

Developers can integrate with it (by making a plugin) to add their own custom options to these menus.

Creating an Action Menu Plugin


What is an Action Menu Plugin?

  • We basically implement a category of the UIResponder class which will be loaded by Action Menu
  • Action Menu also provides us with easy methods to register our new UIMenuController item

The Makefile

The resulting file is a dynamic library (.dylib) so we will create a Makefile for a Library.

ARCHS = armv7 arm64

include theos/makefiles/

AMExample_FILES = AMExample.m
AMExample_INSTALL_PATH = /Library/ActionMenu/Plugins
AMExample_FRAMEWORKS = Foundation UIKit CoreGraphics

include $(THEOS_MAKE_PATH)/

We set the architecture to be armv7 and arm64 (64Bit). Then we include theos' file and after that we define the properties for our Library project.


We will first create our Header File which will not have more than the category interface

#import "ActionMenu.h" //import the Action Menu Header

@interface UIResponder (MyAwesomePlugin) //create our Category
- (BOOL)canPerformAction; //(we will check here if the selected text is longer than 0 characters)
- (void)performMyAction; //this method will do the actual 'work' of our Plugin


We are going to implement the methods and the our category in the .m implementation File.

First we simply include our Header File and write our @implementation section

#import "AMExample.h"

@implementation UIResponder (MyAwesomePlugin)

//our methods here


Using the NSObject's +(void)load method which will be executed earlier than any other method we implement so we can use this to initialize and create our UIMenuController Item.

#import "AMExample.h"

@implementation UIResponder (MyAwesomePlugin)

+ (void)load {

This will call Action Menu's registerAction:title:canPerform method 
which is Action Menu's extension to UIMenuController

[[UIMenuController sharedMenuController] registerAction:@selector(performMyAction) 



Now we have to implement the canPerformAction and performMyAction method. The canPerformAction checks for the length of the selected Text and checks wether it is 0 or higher. It can only perform (return TRUE) when the selected text is longer than 0 characters.

- (BOOL)canPerformAction {

//[self selectedTextualRepresentation] is another Action Menu method
return [[self selectedTextualRepresentation] length] > 0;


And finally the performMyAction method which will in our example case simply show an UIAlertView with the selected Text as a message.

- (void)performMyAction {

//get the selected text
NSString *textSelection = [self selectedTextualRepresentation];

UIAlertView *av = [[UIAlertView alloc] initWithTitle:@"Selected Text" message:textSelection 
[av show]; //shows the alert
[av release]; //releases the object 


And that should be it for your first Action Menu plugin! If you want to adjust it for your Project all you need to do is probably change the category name and the code that will be executed in performMyAction.

External links