Search code examples
iosiphoneios7

how can i know which button is cliked


This is the method execute every time I clicked on any button

- (void)menuButtonClicked:(int)index
{
}

responder of that method is

- (void)onMenuButtonClick:(UIButton*)button
{
    if ([self.delegate respondsToSelector:@selector(menuButtonClicked:)])
        [self.delegate menuButtonClicked:button.tag];
    [self dismissMenuWithSelection:button];
}

My question is I want to print first button, second button is clicked in NSLog


Solution

  • You've everything, you just have to NSLog it :)

    - (void)menuButtonClicked:(int)index
    {
        if(index == 1) {
            NSLog(@"First Button Clicked");
        }
        else if(index == 2) {
            NSLog(@"Second Button Clicked");
        }
        ...
    }