I'm creating my custom UIMenuItem and adding it to shared UIMenuController's menuItems aray:
let menuItemCustom = UIMenuItem(title: "Custom action", action: "customAction:")
UIMenuController.sharedMenuController().menuItems = [menuItemCustom]
Then I enable standard copy
action and my custom action in canPerformAction
function:
func canPerformAction(action: Selector, withSender sender: AnyObject?) -> Bool {
return action == "copy:" || action == "customAction:"
}
Parameter that get passed to my custom action is UIMenuController:
func customAction(menuController: UIMenuController) {
}
Is there a way to pass something else as a parameter, or to have multiple parameteres? When I try to do something like this:
"customAction::"
my custom action simply gets ignored.
Actions such as "customAction:"
get wrapped into an Objective-C Selector.
You cannot pass additional parameters through Selectors.