I'm actually a little bit confused about the changes in iOS7 for displaying a customized context menu on a UITableView.
My code is the following:
- (void)viewDidLoad {
UIMenuItem *deleteAction = [[UIMenuItem alloc]initWithTitle:NSLocalizedString(@"Delete", nil) action:@selector(delete:)];
UIMenuItem *renameAction = [[UIMenuItem alloc]initWithTitle:NSLocalizedString(@"Rename", nil) action:@selector(rename:)];
UIMenuController* mc = [UIMenuController sharedMenuController];
mc.menuItems = [NSArray arrayWithObjects: renameAction, deleteAction, nil];
[mc setTargetRect:CGRectMake(50.0, 50.0, 0, 0) inView:self.view];
[mc setMenuVisible:YES animated:YES];
[mc setMenuItems:@[deleteAction, renameAction]];
[self becomeFirstResponder];
-(void)tableView:(UITableView*)tableView performAction:(SEL)action forRowAtIndexPath:(NSIndexPath*)indexPath withSender:(id)sender{
}
-(BOOL)tableView:(UITableView*)tableView canPerformAction:(SEL)action forRowAtIndexPath:(NSIndexPath*)indexPath withSender:(id)sender {
if (tableView != nil && indexPath != nil)
{
if (action == @selector(delete:)) {
return YES;
}
if (action == @selector(rename:)) {
return YES;
}
}
return NO;
}
-(BOOL)tableView:(UITableView*)tableView shouldShowMenuForRowAtIndexPath:(NSIndexPath*)indexPath {
return YES;
}
My problem is, in previews version of iOS everything works fine. The customized context menu appears if a user long pressed a cell of the tableview, but in iOS7 nothing happens. The methods get called but nothing is shown.