I am working on adding custom UIMenuItem
on tableViewCell. I used this stackoverflow post to to add customMenuItem. This worked fine on ios 6. But it is not at all working on ios 7.
Below is the implementation I have:
In viewDidLoad
:
UIMenuItem *sendByEmailMenuItem = [[UIMenuItem alloc] initWithTitle:@"Send By Email" action:@selector(sendByEmail:)];
[[UIMenuController sharedMenuController] setMenuItems: @[sendByEmailMenuItem]];
[[UIMenuController sharedMenuController] update];
Then adding its delegate
// Shared Menu item delegate actions
- (BOOL)tableView:(UITableView *)tableView shouldShowMenuForRowAtIndexPath:(NSIndexPath *)indexPath {
self.orderAtIndex = [self.orders objectAtIndex:indexPath.row];
[self becomeFirstResponder];
return YES;
}
- (BOOL)tableView:(UITableView *)tableView canPerformAction:(SEL)action forRowAtIndexPath:(NSIndexPath *)indexPath withSender:(id)sender
{
return (action == @selector(sendByEmail:));
}
- (void)tableView:(UITableView *)tableView performAction:(SEL)action forRowAtIndexPath:(NSIndexPath *)indexPath withSender:(id)sender {
if (action == @selector(sendByEmail:)) {
[self sendByEmail:sender];
}
}
// Subclassing Table View cells
-(BOOL) canPerformAction:(SEL)action withSender:(id)sender {
return (action == @selector(sendByEmail:));
}
- (BOOL)canBecomeFirstResponder {
return YES;
}
- (void) sendByEmail: (id) sender {
// Some actions...
}
What I am doing wrong? Any help is appreciated. Thanks