0

I use SWRevealViewController. My goal is to handle the selected menu item in front view via delegate protocol - not via prepareforsegue method.

For example, I'd like to use protocol in rear view class, assign the front view as delegate and when any menu item selected in rear view I will call the delegate method and send the menuItem tag.

The point is I don't know how to assign the front view as delegate to already existed rear view. I can allocate it in code in front view - but for sure this doesn't work. Delegate method isn't called.

Could you please suggest some implementation?

Bogdan Laukhin
  • 1,454
  • 2
  • 17
  • 26

1 Answers1

0

Didn't find the implementations with protocol delegate yet.

I need to handle all menu items selected from the front view - as I open all related windows from there and handle the results there as well.

So I only found the implementation via NSNotificationCenter for posting menu item selected.

This is the code example in rear view (I use tableView for menu view):

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *selectedCell=[tableView cellForRowAtIndexPath:indexPath];
    NSNumber *menuItemTag = [NSNumber numberWithInteger:selectedCell.tag];
    [[NSNotificationCenter defaultCenter] postNotificationName:MENU_ITEM_SELECTED_NOTIFICATION_KEY object:menuItemTag];

    // close menu
    [self.revealViewController revealToggleAnimated:YES];    
}

If you know how to use protocol delegate for this please let me know.

Bogdan Laukhin
  • 1,454
  • 2
  • 17
  • 26