0

I have an array of buttons,I want the text on each button..to be displayed on the label..so friends,please tell me how can I achieve this

Regards Ranjit

Ranjit
  • 4,576
  • 11
  • 62
  • 121

1 Answers1

0

Simply add button in this way

Button.tag = i
[Button addTarget:self action:@selector(MenuDetail:) forControlEvents:UIControlEventTouchUpInside];
[listOfButtons addObject:Button];

and handle touch up event as following

-(IBAction)MenuDetail:(id)sender
{   
    UIButton *temp= (UIButton *)sender;
    NSInteger parentValue=temp.tag;
    clsMenuItem *tempMenu=[appDelegate searchMenu:parentValue];
    if(parentValue==1)
    {
            // do something
    }
    else if(parentValue==1)
    {
        // do something
    }
}

hope this helps

Rupesh
  • 7,866
  • 11
  • 41
  • 58
  • 1
    hey thanks rupesh for your answer,But rupesh,I have an 2D array of buttons,I have created it in code and not in xib,so whether this will work? – Ranjit Nov 16 '11 at 08:15
  • Yes it works since we check the tag of button and apply action according to tag – Rupesh Nov 16 '11 at 12:31