0

I am displaying a context menu on the cells of a table view using UIMenuController.

UIMenuItem *ren = [[UIMenuItem alloc] initWithTitle:@"Rename" action:@selector(onRenameItem:)];
/* .... then set menu visible on long press ...*/

the selector:

-(void) onRenameToken:(id) sender {
        /* ...Identify the selected cell??? ... */ 
    NSLog(@"Cell to be renamed is : %@",cell);
}

My question is how do I identify the cell which needs to be renamed. In other words, identify the cell for which the selector is performing?

PS: New to IOS programming. So pardon any terminology mistakes or silly questions.

Husain Basrawala
  • 1,757
  • 15
  • 21

2 Answers2

0

Maybe the following discussion can help you out a little bit: How to show a custom UIMenuItem for a UITableViewCell? It doesn't seem that straightforward!

Community
  • 1
  • 1
Nenad M
  • 3,055
  • 20
  • 26
0

I would probably subclass UITableViewCell and put the onRenameItem: (or onRenameToken:) method in there.

Since I'm not sure what you mean by "rename" exactly, either the cell could then rename itself or it could send a notification to some controller object to do the actual renaming. Notifications can include an object and/or a user info dictionary, so it could tell the controller its own identity and any other details about what needs to be done.

Phillip Mills
  • 30,888
  • 4
  • 42
  • 57
  • rename is just an action I want to perform on the object displayed in the cell. There are some more options such as delete, activate, synchronize. So basically I want a generic way of identifying the cell for which a context menu is selected. – Husain Basrawala Oct 02 '12 at 07:27
  • Can you elaborate on notification thing with some example or code? Thanks for your reply... – Husain Basrawala Oct 02 '12 at 07:27