So this is the code i have:
UIButton *svObjectButton = [UIButton buttonWithType:UIButtonTypeCustom];
svObjectButton.frame = CGRectMake(0, 0, 100, 100);
[svObjectButton addTarget:self action:@selector(svObjectTouchUpInside) forControlEvents:UIControlEventTouchUpInside];
[svView addSubview:svObjectButton];
UIButton *removeButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
removeButton.frame = CGRectMake(0, 0, 20, 20);
[removeButton addTarget:self action:@selector(removeButtonPressed) forControlEvents:UIControlEventTouchUpInside];
[svObjectButton addSubview:removeButton];
[svObjectButton bringSubviewToFront:removeButton];
But for some reason all touches on removeButton go straight through to svObjectButton.
Any ideas?
I hope you are adding one small button on another big button. To achieve this, you can add
one UIView (for example buttonView) with big button frame size on svView
. After that you can add both buttons on buttonView
(UIview
). You have to avoid:
[svObjectButton addSubview:removeButton];