您可以像这样使用 UIMenuCnotroller:1)创建:
UIMenuController *menuController = [UIMenuController sharedMenuController];
UIMenuItem *open = [[UIMenuItem alloc] initWithTitle:@"Open" action:@selector(open:)];
UIMenuItem *reDownload = [[UIMenuItem alloc] initWithTitle:@"Re-Download" action:@selector(reDownload:)];
[menuController setMenuItems:[NSArray arrayWithObjects:open, reDownload, nil]];
[menuController setTargetRect:cell.frame inView:self.view];
[menuController setMenuVisible:YES animated:YES];
[open release];
[reDownload release];
2)为了捕捉动作应该实现下一个方法:
- (BOOL) canPerformAction:(SEL)selector withSender:(id) sender
{
if (selector == @selector(open:))
{
return YES;
}
if (selector == @selector(reDownload:))
{
return YES;
}
return NO;
}
- (BOOL) canBecomeFirstResponder
{
return YES;
}
3)和实现你的方法:
- (void) open:(id) sender
{
[self doSomething];
}
- (void) reDownload:(id) sender
{
[self doSomething];
}
希望这可以帮助。