-(void)showMenu:(UILongPressGestureRecognizer *)longPressRecognizer
{
longPressRowNum = longPressRecognizer.view.tag;
NSIndexPath *indPath = [NSIndexPath indexPathForRow:longPressRecognizer.view.tag inSection:0];
//Type cast it to CustomCell
UITableViewCell *cell = (UITableViewCell*)[projectTable cellForRowAtIndexPath:indPath];
ProjectDashBoard *projectDashBoard = [listRecord objectAtIndex:longPressRecognizer.view.tag];
NSLog(@"long press project status---%@",projectDashBoard.projectStatus);
if (longPressRecognizer.state == UIGestureRecognizerStateBegan) {
UITableViewCell *selectedCell = (UITableViewCell *)longPressRecognizer.view;
[selectedCell setSelected:YES];
UIMenuItem *delete = [[UIMenuItem alloc] initWithTitle:NSLocalizedString(@"deleteproject", nil) action:@selector(deleteClicked:)];
UIMenuController *menu = [UIMenuController sharedMenuController];
if([projectDashBoard.projectStatus isEqualToString:statusActive]){
UIMenuItem *archive = [[UIMenuItem alloc] initWithTitle:NSLocalizedString(@"archiveproject", nil) action:@selector(archiveClicked:)];
[menu setMenuItems:[NSArray arrayWithObjects:delete, archive, nil]];
}else{
UIMenuItem *archive = [[UIMenuItem alloc] initWithTitle:NSLocalizedString(@"unarchiveproject", nil) action:@selector(archiveClicked:)];
[menu setMenuItems:[NSArray arrayWithObjects:delete, archive, nil]];
}
[[UIMenuController sharedMenuController] update];
[menu setTargetRect:cell.frame inView:cell.superview];
[menu setMenuVisible:YES animated:YES];
}
}