1) rewriteCanbecomefirstresponderMethod
-(Bool) canbecomefirstresponder {
[Super canbecomefirstresponder];
Return yes;
}
2) create a customUimenucontroller
Uimenuitem * share = [[uimenuitem alloc] initwithtitle: @ "share" Action: @ selector (share :)];
Uimenuitem * Email = [[uimenuitem alloc] initwithtitle: @ "email" Action: @ selector (email :)];
Uimenuitem * print = [[uimenuitem alloc] initwithtitle: @ "print" Action: @ selector (print :)];
Uimenucontroller * menu = [uimenucontroller sharedmenucontroller];
[Menu setmenuitems: [nsarrayarraywithobjects: Share, email, print, nil];
[Menu settargetrect: Self. frameinview: Self. superview];
[Menu setmenuvisible: yesanimated: Yes];
(3) determine which menu to display
-(Bool) can1_maction :( SEL) actionwithsender :( ID) sender
{
[Super canperformaction: actionwithsender: sender];
If (Action = @ selector (share :) | action = @ selector (email :) | action = @ selector (print :))
{
Returnyes;
}
Else
{
Returnno;
}
}