UIMenuController needs a better means to determine which UIMenuItem was tapped

Originator:gwynne
Number:rdar://11441786 Date Originated:13-May-2012 08:18 AM
Status:Open Resolved:
Product:iOS SDK Product Version:5.1
Classification:Enhancement Reproducible:N/A
 
Summary:
UIMenuController always sends the action message of a UIMenuItem to the first responder, and uses the controller object as the sender, rather than the menu item. As a result, the only way for code to determine which item was tapped is to use different selectors. Among other things, this makes it entirely impossible to use a block as the action for a UIMenuItem; the methods that allow other subsystems to make use of blocks are defeated by the inability to specify a target and the passing of a generic sender to the action.

The preferred solution is to enhance UIMenuItem to take a "target" parameter in the style of other target/action objects (such as UIBarButtonItem). For backwards compatibility, allow a nil "target" to represent "send to the first responder".

A secondary solution that does not require an API change is to pass the UIMenuItem to the action method rather than the UIMenuController. Backwards compatibility issues are minimal, as there is only one shared UIMenuController at any time, and the nature of the sender parameter to the action method is undocumented.

Steps to Reproduce:
N/A

Expected Results:
N/A

Actual Results:
N/A

Regression:
Since UIMenuController was introduced.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!