I'm trying to make two custom buttons in code. One that fills the full screen with a small button on top. The problem I'm having is the larger button is triggered when the smaller button is tapped. I've tried doing exactly the same thing with IB and it works. Is there some sort of trapping/masking method that I need to use with code? I've checked the documentation and not come across anything that would suggest why this is happening.
CGRect bFrame = CGRectMake(0, 0, 320, 480);
UIButton *cancelButton = [[UIButton alloc] init];
cancelButton = [UIButton buttonWithType:UIButtonTypeCustom];
cancelButton.frame = bFrame;
[cancelButton setBackgroundColor:[UIColor clearColor]];
[cancelButton addTarget:self action:@selector(animate:) forControlEvents:UIControlEventTouchUpInside];
UIButton *priceButton = [[UIButton alloc] init];
priceButton.center = CGPointMake(228, 98);
[priceButton addTarget:self action:@selector(callNumber:) forControlEvents:UIControlEventTouchUpInside];
[priceButton setTitle:@"BUY" forState:UIControlStateNormal];
[self.view addSubview:priceButton];
//[cancelButton addSubview:priceButton];
[self.view addSubview:cancelButton];
[self.view bringSubviewToFront:priceButton];