views:

25

answers:

0

I have the following code. I am creating 3 buttons. They show up in my app. Event handler for the 1st button get's called when I click on it but NOT for the last 2. What am I doing wrong?

THE FOLLOWING WORKS PROPERLY.

         UIButton *invite = [[UIButton alloc] initWithFrame:CGRectMake(x, 0, 40, 15)]; 
    [invite setTitle:@"invite" forState:UIControlStateNormal]; //boldSystemFontOfSize

    // set TAG to to index in resultData tab.       
    invite.tag =  [resultData indexOfObject:circle];
    //NSLog(@"%d",invite.tag);
    //invite.titleLabel.font = [UIFont fontWithName:@"Georgia" size:8];
    invite.titleLabel.font = [UIFont boldSystemFontOfSize:10];
    UIImage *blueImage = [UIImage imageNamed:@"blue.png"];
    UIImage *blueButtonImage = [blueImage stretchableImageWithLeftCapWidth:12 topCapHeight:0];
    [invite setBackgroundImage:blueButtonImage forState:UIControlStateNormal];
    [invite addTarget:self action:@selector(inviteEvent:) forControlEvents:UIControlEventTouchUpInside]; // THIS IS BEING CALLED.
    [inviteView addSubview:invite];
    x += 50;

// THE FOLLOWING 2 does not work properly.

    UIButton *allow = [[UIButton alloc] initWithFrame:CGRectMake(x, 0, 30, 15)]; 
    [allow setTitle:@"allow" forState:UIControlStateNormal]; //boldSystemFontOfSize

    // set TAG to to index in resultData tab.       
    allow.tag =  [resultData indexOfObject:circle];
    //NSLog(@"%d",invite.tag);
    //invite.titleLabel.font = [UIFont fontWithName:@"Georgia" size:8];
    allow.titleLabel.font = [UIFont boldSystemFontOfSize:10];
    UIImage *blueImage = [UIImage imageNamed:@"green.png"];
    UIImage *blueButtonImage = [blueImage stretchableImageWithLeftCapWidth:12 topCapHeight:0];
    [allow setBackgroundImage:blueButtonImage forState:UIControlStateNormal];
    [allow addTarget:self action:@selector(allowDenyEvent:) forControlEvents:UIControlEventTouchUpInside]; // THIS EVENT HANDLER IS NOT BEING CALLED.
    [inviteView addSubview:allow];
    x += 30;

    UIButton *deny = [[UIButton alloc] initWithFrame:CGRectMake(x, 0, 30, 15)]; 
    [deny setTitle:@"deny" forState:UIControlStateNormal]; //boldSystemFontOfSize

    // set TAG to to index in resultData tab.       
    deny.tag =  [resultData indexOfObject:circle];
    //NSLog(@"%d",invite.tag);
    //invite.titleLabel.font = [UIFont fontWithName:@"Georgia" size:8];
    deny.titleLabel.font = [UIFont boldSystemFontOfSize:10];
    UIImage *redImage = [UIImage imageNamed:@"red.png"];
    UIImage *redButtonImage = [redImage stretchableImageWithLeftCapWidth:12 topCapHeight:0];
    [deny setBackgroundImage:redButtonImage forState:UIControlStateNormal];
    [deny addTarget:self action:@selector(allowDenyEvent:) forControlEvents:UIControlEventTouchUpInside];  // AS YOU CAN SEE I AM ADDING THE EVENT HANDLER HERE.
    [inviteView addSubview:deny];
    x += 40;

WHAT AM I DOING WRONG? ANY HELP will be greatly appreciated.

Thanks Amitabh